summaryrefslogtreecommitdiffstats
path: root/drivers/net/hamradio
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2017-05-06 17:42:22 +0200
committerDavid S. Miller <davem@davemloft.net>2017-05-08 21:02:10 +0200
commit871ff2ebe0af0d7f1050bfc8bce62fddea2b12ec (patch)
tree2a1ad5d19e8c0902c8d265d4ff05afce75fe8a50 /drivers/net/hamradio
parentnet/hippi/rrunner: use memdup_user (diff)
downloadlinux-871ff2ebe0af0d7f1050bfc8bce62fddea2b12ec.tar.xz
linux-871ff2ebe0af0d7f1050bfc8bce62fddea2b12ec.zip
yam: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hamradio')
-rw-r--r--drivers/net/hamradio/yam.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index b6891ada1d7b..7a7c5224a336 100644
--- a/drivers/net/hamradio/yam.c
+++ b/drivers/net/hamradio/yam.c
@@ -976,12 +976,10 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case SIOCYAMSMCS:
if (netif_running(dev))
return -EINVAL; /* Cannot change this parameter when up */
- if ((ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL)) == NULL)
- return -ENOBUFS;
- if (copy_from_user(ym, ifr->ifr_data, sizeof(struct yamdrv_ioctl_mcs))) {
- kfree(ym);
- return -EFAULT;
- }
+ ym = memdup_user(ifr->ifr_data,
+ sizeof(struct yamdrv_ioctl_mcs));
+ if (IS_ERR(ym))
+ return PTR_ERR(ym);
if (ym->bitrate > YAM_MAXBITRATE) {
kfree(ym);
return -EINVAL;