* [PATCH] [WAN]: lmc: Use memdup_user() as a cleanup
@ 2017-11-22 15:29 Vasyl Gomonovych
2017-11-28 15:58 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Vasyl Gomonovych @ 2017-11-22 15:29 UTC (permalink / raw)
To: netdev; +Cc: linux-kernel, gomonovych
Fix coccicheck warning which recommends to use memdup_user():
drivers/net/wan/lmc/lmc_main.c:497:27-34: WARNING opportunity for memdup_user
Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
---
drivers/net/wan/lmc/lmc_main.c | 13 +++----------
1 file changed, 3 insertions(+), 10 deletions(-)
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index 4698450c77d1..ded78a466fe3 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -494,18 +494,11 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
break;
}
- data = kmalloc(xc.len, GFP_KERNEL);
- if (!data) {
- ret = -ENOMEM;
+ data = memdup_user(xc.data, xc.len);
+ if (IS_ERR(data)) {
+ ret = PTR_ERR(data);
break;
}
-
- if(copy_from_user(data, xc.data, xc.len))
- {
- kfree(data);
- ret = -ENOMEM;
- break;
- }
printk("%s: Starting load of data Len: %d at 0x%p == 0x%p\n", dev->name, xc.len, xc.data, data);
--
1.9.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] [WAN]: lmc: Use memdup_user() as a cleanup
2017-11-22 15:29 [PATCH] [WAN]: lmc: Use memdup_user() as a cleanup Vasyl Gomonovych
@ 2017-11-28 15:58 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2017-11-28 15:58 UTC (permalink / raw)
To: gomonovych; +Cc: netdev, linux-kernel
From: Vasyl Gomonovych <gomonovych@gmail.com>
Date: Wed, 22 Nov 2017 16:29:57 +0100
> Fix coccicheck warning which recommends to use memdup_user():
> drivers/net/wan/lmc/lmc_main.c:497:27-34: WARNING opportunity for memdup_user
> Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
>
> Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Applied.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2017-11-28 15:58 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-22 15:29 [PATCH] [WAN]: lmc: Use memdup_user() as a cleanup Vasyl Gomonovych
2017-11-28 15:58 ` David Miller
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).