lkml.org 
[lkml]   [2016]   [Aug]   [20]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation
Date
Le 20/08/2016 à 10:25, SF Markus Elfring a écrit :
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Sat, 20 Aug 2016 10:10:12 +0200
>
> Reuse existing functionality from memdup_user() instead of keeping
> duplicate source code.
>
> This issue was detected by using the Coccinelle software.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
> drivers/net/wan/cosa.c | 12 +++---------
> 1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/net/wan/cosa.c b/drivers/net/wan/cosa.c
> index b87fe0a..02f5809 100644
> --- a/drivers/net/wan/cosa.c
> +++ b/drivers/net/wan/cosa.c
> @@ -875,16 +875,10 @@ static ssize_t cosa_write(struct file *file,
> if (count > COSA_MTU)
> count = COSA_MTU;
>
> - /* Allocate the buffer */
> - kbuf = kmalloc(count, GFP_KERNEL|GFP_DMA);
In this case, 'memdup_user()' has a different meaning, as GFP_DMA will
no more be used for this memory allocation.

> - if (kbuf == NULL) {
> + kbuf = memdup_user(buf, count);
> + if (IS_ERR(kbuf)) {
> up(&chan->wsem);
> - return -ENOMEM;
> - }
> - if (copy_from_user(kbuf, buf, count)) {
> - up(&chan->wsem);
> - kfree(kbuf);
> - return -EFAULT;
> + return PTR_ERR(kbuf);
> }
> chan->tx_status=0;
> cosa_start_tx(chan, kbuf, count);



---
L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
https://www.avast.com/antivirus


\
 
 \ /
  Last update: 2016-09-17 09:57    [W:0.050 / U:0.052 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site