All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] cifs: NULL dereference on allocation failure
@ 2012-01-24  8:39 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-01-24  8:39 UTC (permalink / raw)
  To: Steve French
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

We should just return directly here, the goto causes a NULL dereference.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 986709a..026d646 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
 	struct smb_vol *vol_info;
 
 	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
-	if (vol_info = NULL) {
-		tcon = ERR_PTR(-ENOMEM);
-		goto out;
-	}
+	if (vol_info = NULL)
+		return ERR_PTR(-ENOMEM);
 
 	vol_info->local_nls = cifs_sb->local_nls;
 	vol_info->linux_uid = fsuid;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [patch] cifs: NULL dereference on allocation failure
@ 2012-01-24  8:39 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: Dan Carpenter @ 2012-01-24  8:39 UTC (permalink / raw)
  To: Steve French
  Cc: linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

We should just return directly here, the goto causes a NULL dereference.

Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>

diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
index 986709a..026d646 100644
--- a/fs/cifs/connect.c
+++ b/fs/cifs/connect.c
@@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
 	struct smb_vol *vol_info;
 
 	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
-	if (vol_info == NULL) {
-		tcon = ERR_PTR(-ENOMEM);
-		goto out;
-	}
+	if (vol_info == NULL)
+		return ERR_PTR(-ENOMEM);
 
 	vol_info->local_nls = cifs_sb->local_nls;
 	vol_info->linux_uid = fsuid;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
       [not found] ` <20120124083922.GA29097-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
@ 2012-01-24 12:41     ` Jeff Layton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2012-01-24 12:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, 24 Jan 2012 11:39:22 +0300
Dan Carpenter <dan.carpenter@oracle.com> wrote:

> We should just return directly here, the goto causes a NULL dereference.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 986709a..026d646 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
>  	struct smb_vol *vol_info;
>  
>  	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> -	if (vol_info = NULL) {
> -		tcon = ERR_PTR(-ENOMEM);
> -		goto out;
> -	}
> +	if (vol_info = NULL)
> +		return ERR_PTR(-ENOMEM);
>  
>  	vol_info->local_nls = cifs_sb->local_nls;
>  	vol_info->linux_uid = fsuid;

Huh? How so? Here's what "out:" looks like in my tree:

---------------[snip]----------------
out:
        kfree(vol_info);

        return tcon;
---------------[snip]----------------

vol_info is NULL, so the kfree is safe. This patch shouldn't break
anything, but I don't think it's strictly necessary.

-- 
Jeff Layton <jlayton@samba.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
@ 2012-01-24 12:41     ` Jeff Layton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2012-01-24 12:41 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, 24 Jan 2012 11:39:22 +0300
Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote:

> We should just return directly here, the goto causes a NULL dereference.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> 
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 986709a..026d646 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
>  	struct smb_vol *vol_info;
>  
>  	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> -	if (vol_info == NULL) {
> -		tcon = ERR_PTR(-ENOMEM);
> -		goto out;
> -	}
> +	if (vol_info == NULL)
> +		return ERR_PTR(-ENOMEM);
>  
>  	vol_info->local_nls = cifs_sb->local_nls;
>  	vol_info->linux_uid = fsuid;

Huh? How so? Here's what "out:" looks like in my tree:

---------------[snip]----------------
out:
        kfree(vol_info);

        return tcon;
---------------[snip]----------------

vol_info is NULL, so the kfree is safe. This patch shouldn't break
anything, but I don't think it's strictly necessary.

-- 
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
       [not found]     ` <20120124074104.095f8755-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
@ 2012-01-24 12:43         ` Jeff Layton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2012-01-24 12:43 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Dan Carpenter, Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, 24 Jan 2012 07:41:04 -0500
Jeff Layton <jlayton@samba.org> wrote:

> On Tue, 24 Jan 2012 11:39:22 +0300
> Dan Carpenter <dan.carpenter@oracle.com> wrote:
> 
> > We should just return directly here, the goto causes a NULL dereference.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 986709a..026d646 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
> >  	struct smb_vol *vol_info;
> >  
> >  	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> > -	if (vol_info = NULL) {
> > -		tcon = ERR_PTR(-ENOMEM);
> > -		goto out;
> > -	}
> > +	if (vol_info = NULL)
> > +		return ERR_PTR(-ENOMEM);
> >  
> >  	vol_info->local_nls = cifs_sb->local_nls;
> >  	vol_info->linux_uid = fsuid;
> 
> Huh? How so? Here's what "out:" looks like in my tree:
> 
> ---------------[snip]----------------
> out:
>         kfree(vol_info);
> 
>         return tcon;
> ---------------[snip]----------------
> 
> vol_info is NULL, so the kfree is safe. This patch shouldn't break
> anything, but I don't think it's strictly necessary.
> 

Sorry, I was looking at the wrong branch. The patch is correct and
necessary. With the most recent changes, here's what "out:" looks like:

---------------[snip]----------------
out:
        kfree(vol_info->username);
        kfree(vol_info->password);
        kfree(vol_info);
---------------[snip]----------------

Reviewed-by: Jeff Layton <jlayton@redhat.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
@ 2012-01-24 12:43         ` Jeff Layton
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Layton @ 2012-01-24 12:43 UTC (permalink / raw)
  To: Jeff Layton
  Cc: Dan Carpenter, Steve French, linux-cifs-u79uwXL29TY76Z2rM5mHXA,
	samba-technical-w/Ol4Ecudpl8XjKLYN78aQ,
	kernel-janitors-u79uwXL29TY76Z2rM5mHXA

On Tue, 24 Jan 2012 07:41:04 -0500
Jeff Layton <jlayton-eUNUBHrolfbYtjvyW6yDsg@public.gmane.org> wrote:

> On Tue, 24 Jan 2012 11:39:22 +0300
> Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org> wrote:
> 
> > We should just return directly here, the goto causes a NULL dereference.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>
> > 
> > diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> > index 986709a..026d646 100644
> > --- a/fs/cifs/connect.c
> > +++ b/fs/cifs/connect.c
> > @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
> >  	struct smb_vol *vol_info;
> >  
> >  	vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> > -	if (vol_info == NULL) {
> > -		tcon = ERR_PTR(-ENOMEM);
> > -		goto out;
> > -	}
> > +	if (vol_info == NULL)
> > +		return ERR_PTR(-ENOMEM);
> >  
> >  	vol_info->local_nls = cifs_sb->local_nls;
> >  	vol_info->linux_uid = fsuid;
> 
> Huh? How so? Here's what "out:" looks like in my tree:
> 
> ---------------[snip]----------------
> out:
>         kfree(vol_info);
> 
>         return tcon;
> ---------------[snip]----------------
> 
> vol_info is NULL, so the kfree is safe. This patch shouldn't break
> anything, but I don't think it's strictly necessary.
> 

Sorry, I was looking at the wrong branch. The patch is correct and
necessary. With the most recent changes, here's what "out:" looks like:

---------------[snip]----------------
out:
        kfree(vol_info->username);
        kfree(vol_info->password);
        kfree(vol_info);
---------------[snip]----------------

Reviewed-by: Jeff Layton <jlayton-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
  2012-01-24  8:39 ` Dan Carpenter
@ 2012-01-24 16:37   ` Steve French
  -1 siblings, 0 replies; 8+ messages in thread
From: Steve French @ 2012-01-24 16:37 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Steve French, linux-cifs, kernel-janitors, samba-technical

Merged into cifs-2.6.git

On Tue, Jan 24, 2012 at 2:39 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We should just return directly here, the goto causes a NULL dereference.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 986709a..026d646 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
>        struct smb_vol *vol_info;
>
>        vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> -       if (vol_info = NULL) {
> -               tcon = ERR_PTR(-ENOMEM);
> -               goto out;
> -       }
> +       if (vol_info = NULL)
> +               return ERR_PTR(-ENOMEM);
>
>        vol_info->local_nls = cifs_sb->local_nls;
>        vol_info->linux_uid = fsuid;



-- 
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [patch] cifs: NULL dereference on allocation failure
@ 2012-01-24 16:37   ` Steve French
  0 siblings, 0 replies; 8+ messages in thread
From: Steve French @ 2012-01-24 16:37 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: Steve French, linux-cifs, kernel-janitors, samba-technical

Merged into cifs-2.6.git

On Tue, Jan 24, 2012 at 2:39 AM, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> We should just return directly here, the goto causes a NULL dereference.
>
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>
> diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c
> index 986709a..026d646 100644
> --- a/fs/cifs/connect.c
> +++ b/fs/cifs/connect.c
> @@ -3857,10 +3857,8 @@ cifs_construct_tcon(struct cifs_sb_info *cifs_sb, uid_t fsuid)
>        struct smb_vol *vol_info;
>
>        vol_info = kzalloc(sizeof(*vol_info), GFP_KERNEL);
> -       if (vol_info == NULL) {
> -               tcon = ERR_PTR(-ENOMEM);
> -               goto out;
> -       }
> +       if (vol_info == NULL)
> +               return ERR_PTR(-ENOMEM);
>
>        vol_info->local_nls = cifs_sb->local_nls;
>        vol_info->linux_uid = fsuid;



-- 
Thanks,

Steve

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-24 16:37 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-24  8:39 [patch] cifs: NULL dereference on allocation failure Dan Carpenter
2012-01-24  8:39 ` Dan Carpenter
     [not found] ` <20120124083922.GA29097-mgFCXtclrQlZLf2FXnZxJA@public.gmane.org>
2012-01-24 12:41   ` Jeff Layton
2012-01-24 12:41     ` Jeff Layton
     [not found]     ` <20120124074104.095f8755-9yPaYZwiELC+kQycOl6kW4xkIHaj4LzF@public.gmane.org>
2012-01-24 12:43       ` Jeff Layton
2012-01-24 12:43         ` Jeff Layton
2012-01-24 16:37 ` Steve French
2012-01-24 16:37   ` Steve French

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.