linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] usb: testing the wrong variable in fs_create_by_name()
@ 2010-04-22 10:00 Dan Carpenter
  2010-04-22 16:24 ` Greg KH
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2010-04-22 10:00 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Alessio Igor Bogani, linux-usb, linux-kernel, kernel-janitors

There is a typo here.  We should be testing "*dentry" which was just
assigned instead of "dentry".  This could result in dereferencing an
ERR_PTR inside either usbfs_mkdir() or usbfs_create().

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/drivers/usb/core/inode.c b/drivers/usb/core/inode.c
index 97b40ce..4a6366a 100644
--- a/drivers/usb/core/inode.c
+++ b/drivers/usb/core/inode.c
@@ -515,13 +515,13 @@ static int fs_create_by_name (const char *name, mode_t mode,
 	*dentry = NULL;
 	mutex_lock(&parent->d_inode->i_mutex);
 	*dentry = lookup_one_len(name, parent, strlen(name));
-	if (!IS_ERR(dentry)) {
+	if (!IS_ERR(*dentry)) {
 		if ((mode & S_IFMT) == S_IFDIR)
 			error = usbfs_mkdir (parent->d_inode, *dentry, mode);
 		else 
 			error = usbfs_create (parent->d_inode, *dentry, mode);
 	} else
-		error = PTR_ERR(dentry);
+		error = PTR_ERR(*dentry);
 	mutex_unlock(&parent->d_inode->i_mutex);
 
 	return error;

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

* Re: [patch] usb: testing the wrong variable in fs_create_by_name()
  2010-04-22 10:00 [patch] usb: testing the wrong variable in fs_create_by_name() Dan Carpenter
@ 2010-04-22 16:24 ` Greg KH
  0 siblings, 0 replies; 2+ messages in thread
From: Greg KH @ 2010-04-22 16:24 UTC (permalink / raw)
  To: Dan Carpenter, Greg Kroah-Hartman, Alessio Igor Bogani, linux-usb,
	linux-kernel, kernel-janitors

On Thu, Apr 22, 2010 at 12:00:52PM +0200, Dan Carpenter wrote:
> There is a typo here.  We should be testing "*dentry" which was just
> assigned instead of "dentry".  This could result in dereferencing an
> ERR_PTR inside either usbfs_mkdir() or usbfs_create().
> 
> Signed-off-by: Dan Carpenter <error27@gmail.com>

Nice catch, thanks.  I'll go queue this up.

greg k-h

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

end of thread, other threads:[~2010-04-22 16:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-22 10:00 [patch] usb: testing the wrong variable in fs_create_by_name() Dan Carpenter
2010-04-22 16:24 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).