From: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
To: linux-kernel@vger.kernel.org
Cc: netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation
Date: Sat, 20 Aug 2016 10:42:54 +0200 [thread overview]
Message-ID: <np956e$tnp$1@blaine.gmane.org> (raw)
In-Reply-To: <5d335025-5f52-d4b6-0b60-89a2fd354694@users.sourceforge.net>
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
next prev parent reply other threads:[~2016-08-20 8:43 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-20 8:25 [PATCH] wan-cosa: Use memdup_user() rather than duplicating its implementation SF Markus Elfring
2016-08-20 8:25 ` SF Markus Elfring
2016-08-20 8:42 ` Christophe JAILLET [this message]
2016-08-21 2:12 ` David Miller
2016-08-21 2:12 ` David Miller
2016-08-24 15:21 ` Jan Kasprzak
2016-08-24 15:21 ` Jan Kasprzak
2016-08-24 16:14 ` SF Markus Elfring
2016-08-24 16:14 ` SF Markus Elfring
2016-08-25 9:13 ` Jan Kasprzak
2016-08-25 9:13 ` Jan Kasprzak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='np956e$tnp$1@blaine.gmane.org' \
--to=christophe.jaillet@wanadoo.fr \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.