[lxc-devel] [PATCH] don't dereference a NULL c->lxc_conf

Stéphane Graber stgraber at ubuntu.com
Wed Jun 3 18:09:23 UTC 2015


On Wed, Jun 03, 2015 at 05:20:19PM +0000, Serge Hallyn wrote:
> Commit 37cf711b added a destroy hook, but when it checks
> at destroy time whether that hook exists, it assumes that
> c->lxc_conf is good.  In fact lxc_conf can be NULL, so check
> for that.
> 
> Signed-off-by: Serge Hallyn <serge.hallyn at ubuntu.com>

Acked-by: Stéphane Graber <stgraber at ubuntu.com>

> ---
>  src/lxc/lxccontainer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/src/lxc/lxccontainer.c b/src/lxc/lxccontainer.c
> index 916c99c..445cc22 100644
> --- a/src/lxc/lxccontainer.c
> +++ b/src/lxc/lxccontainer.c
> @@ -2160,11 +2160,12 @@ static bool container_destroy(struct lxc_container *c)
>  {
>  	bool bret = false;
>  	int ret;
> -	struct lxc_conf *conf = c->lxc_conf;
> +	struct lxc_conf *conf;
>  
>  	if (!c || !do_lxcapi_is_defined(c))
>  		return false;
>  
> +	conf = c->lxc_conf;
>  	if (container_disk_lock(c))
>  		return false;
>  
> @@ -2174,7 +2175,7 @@ static bool container_destroy(struct lxc_container *c)
>  		goto out;
>  	}
>  
> -	if (!lxc_list_empty(&conf->hooks[LXCHOOK_DESTROY])) {
> +	if (conf && !lxc_list_empty(&conf->hooks[LXCHOOK_DESTROY])) {
>  		/* Start of environment variable setup for hooks */
>  		if (setenv("LXC_NAME", c->name, 1)) {
>  			SYSERROR("failed to set environment variable for container name");
> -- 
> 2.1.4
> 
> _______________________________________________
> lxc-devel mailing list
> lxc-devel at lists.linuxcontainers.org
> http://lists.linuxcontainers.org/listinfo/lxc-devel

-- 
Stéphane Graber
Ubuntu developer
http://www.ubuntu.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20150603/1e2eff71/attachment.sig>


More information about the lxc-devel mailing list