Re: [PATCH] usb/musb: debugfs, fix copy_from_user argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jan 14, 2015 at 05:12:55PM +0100, 'Markus Pargmann' wrote:
> Hi,
> 
> On Wed, Jan 14, 2015 at 03:19:42PM +0000, David Laight wrote:
> > From: Markus Pargmann
> > > The first arugment has to be a pointer to the memory. buf is a char
> > > array and already a pointer itself. The current code passes a pointer to
> > > a char array to copy_from_user() which is not correct.
> > 
> > It doesn't matter, while the type of the argument is subtly different the
> > value passed is the same.
> 
> Thanks, I didn't know about this. So the code is actually correct and
> the patch is not a fix. I would still prefer to have it consistent with
> the usage of 'buf' in the code above and below, where 'buf' is directly
> used.

I modified it like so:

commit 5db92ebc06ad815a4032f28145531a879b73db08
Author: Markus Pargmann <mpa@xxxxxxxxxxxxxx>
Date:   Wed Jan 14 16:08:38 2015 +0100

    usb: musb: debugfs: improve copy_from_user() argument
    
    While the code is correct and functions well, it's still
    a bit misleading to add the reference operator in from of
    the buf argument.
    
    This patch simply removes that operator in order to make
    use of buf slightly better to the eyes.
    
    Signed-off-by: Markus Pargmann <mpa@xxxxxxxxxxxxxx>
    Signed-off-by: Felipe Balbi <balbi@xxxxxx>

diff --git a/drivers/usb/musb/musb_debugfs.c b/drivers/usb/musb/musb_debugfs.c
index ad3701a97389..bb13e0420140 100644
--- a/drivers/usb/musb/musb_debugfs.c
+++ b/drivers/usb/musb/musb_debugfs.c
@@ -194,7 +194,7 @@ static ssize_t musb_test_mode_write(struct file *file,
 
 	memset(buf, 0x00, sizeof(buf));
 
-	if (copy_from_user(&buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
+	if (copy_from_user(buf, ubuf, min_t(size_t, sizeof(buf) - 1, count)))
 		return -EFAULT;
 
 	if (!strncmp(buf, "force host", 9))

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux