linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] agp: use memdup_user
@ 2017-05-06 15:42 Geliang Tang
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: " Geliang Tang
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: David Airlie; +Cc: Geliang Tang, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/char/agp/compat_ioctl.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c
index 2053f70..a0a3cf0 100644
--- a/drivers/char/agp/compat_ioctl.c
+++ b/drivers/char/agp/compat_ioctl.c
@@ -98,9 +98,10 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 		if (ureserve.seg_count >= 16384)
 			return -EINVAL;
 
-		usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
-		if (!usegment)
-			return -ENOMEM;
+		usegment = memdup_user((void __user *)ureserve.seg_list,
+				       sizeof(*usegment) * ureserve.seg_count);
+		if (IS_ERR(usegment))
+			return PTR_ERR(usegment);
 
 		ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
 		if (!ksegment) {
@@ -108,13 +109,6 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 			return -ENOMEM;
 		}
 
-		if (copy_from_user(usegment, (void __user *) ureserve.seg_list,
-				   sizeof(*usegment) * ureserve.seg_count)) {
-			kfree(usegment);
-			kfree(ksegment);
-			return -EFAULT;
-		}
-
 		for (seg = 0; seg < ureserve.seg_count; seg++) {
 			ksegment[seg].pg_start = usegment[seg].pg_start;
 			ksegment[seg].pg_count = usegment[seg].pg_count;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] net/hippi/rrunner: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-08 19:02   ` David Miller
  2017-05-06 15:42 ` [PATCH] spi: spidev: " Geliang Tang
                   ` (5 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Jes Sorensen; +Cc: Geliang Tang, linux-hippi, netdev, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/net/hippi/rrunner.c | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index 9b0d614..1ce6239 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1616,17 +1616,14 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 			return -EPERM;
 		}
 
-		image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
-		oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
-		if (!image || !oldimage) {
-			error = -ENOMEM;
-			goto wf_out;
-		}
+		image = memdup_user(rq->ifr_data, EEPROM_BYTES);
+		if (IS_ERR(image))
+			return PTR_ERR(image);
 
-		error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
-		if (error) {
-			error = -EFAULT;
-			goto wf_out;
+		oldimage = kmalloc(EEPROM_BYTES, GFP_KERNEL);
+		if (!oldimage) {
+			kfree(image);
+			return -ENOMEM;
 		}
 
 		if (rrpriv->fw_running){
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] spi: spidev: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: " Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-08  9:28   ` Geert Uytterhoeven
  2017-05-15  8:05   ` Applied "spi: spidev: use memdup_user" to the spi tree Mark Brown
  2017-05-06 15:42 ` [PATCH] usb: cdc-wdm: use memdup_user Geliang Tang
                   ` (4 subsequent siblings)
  6 siblings, 2 replies; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Mark Brown; +Cc: Geliang Tang, linux-spi, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/spi/spidev.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 9a2a79a..b00a88f 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -325,7 +325,6 @@ static struct spi_ioc_transfer *
 spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
 		unsigned *n_ioc)
 {
-	struct spi_ioc_transfer	*ioc;
 	u32	tmp;
 
 	/* Check type, command number and direction */
@@ -342,14 +341,7 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
 		return NULL;
 
 	/* copy into scratch area */
-	ioc = kmalloc(tmp, GFP_KERNEL);
-	if (!ioc)
-		return ERR_PTR(-ENOMEM);
-	if (__copy_from_user(ioc, u_ioc, tmp)) {
-		kfree(ioc);
-		return ERR_PTR(-EFAULT);
-	}
-	return ioc;
+	return memdup_user(u_ioc, tmp);
 }
 
 static long
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] usb: cdc-wdm: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: " Geliang Tang
  2017-05-06 15:42 ` [PATCH] spi: spidev: " Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-06 17:40   ` Bjørn Mork
  2017-05-06 15:42 ` [PATCH] wil6210: " Geliang Tang
                   ` (3 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oliver Neukum, Bjørn Mork
  Cc: Geliang Tang, linux-usb, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/usb/class/cdc-wdm.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 08669fe..0e4f18c 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -361,17 +361,9 @@ static ssize_t wdm_write
 	if (we < 0)
 		return usb_translate_errors(we);
 
-	buf = kmalloc(count, GFP_KERNEL);
-	if (!buf) {
-		rv = -ENOMEM;
-		goto outnl;
-	}
-
-	r = copy_from_user(buf, buffer, count);
-	if (r > 0) {
-		rv = -EFAULT;
-		goto out_free_mem;
-	}
+	buf = memdup_user(buffer, count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
 
 	/* concurrent writes and disconnect */
 	r = mutex_lock_interruptible(&desc->wlock);
@@ -441,7 +433,6 @@ static ssize_t wdm_write
 
 	usb_autopm_put_interface(desc->intf);
 	mutex_unlock(&desc->wlock);
-outnl:
 	return rv < 0 ? rv : count;
 
 out_free_mem_pm:
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] wil6210: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
                   ` (2 preceding siblings ...)
  2017-05-06 15:42 ` [PATCH] usb: cdc-wdm: use memdup_user Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-19  7:55   ` Kalle Valo
  2017-05-06 15:42 ` [PATCH] wlcore: " Geliang Tang
                   ` (2 subsequent siblings)
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Maya Erez, Kalle Valo
  Cc: Geliang Tang, linux-wireless, wil6210, netdev, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/net/wireless/ath/wil6210/debugfs.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/net/wireless/ath/wil6210/debugfs.c b/drivers/net/wireless/ath/wil6210/debugfs.c
index 5648ebb..5b0f9fc 100644
--- a/drivers/net/wireless/ath/wil6210/debugfs.c
+++ b/drivers/net/wireless/ath/wil6210/debugfs.c
@@ -795,15 +795,11 @@ static ssize_t wil_write_file_txmgmt(struct file *file, const char __user *buf,
 	struct wireless_dev *wdev = wil_to_wdev(wil);
 	struct cfg80211_mgmt_tx_params params;
 	int rc;
-	void *frame = kmalloc(len, GFP_KERNEL);
+	void *frame;
 
-	if (!frame)
-		return -ENOMEM;
-
-	if (copy_from_user(frame, buf, len)) {
-		kfree(frame);
-		return -EIO;
-	}
+	frame = memdup_user(buf, len);
+	if (IS_ERR(frame))
+		return PTR_ERR(frame);
 
 	params.buf = frame;
 	params.len = len;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] wlcore: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
                   ` (3 preceding siblings ...)
  2017-05-06 15:42 ` [PATCH] wil6210: " Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-18 13:41   ` Kalle Valo
  2017-05-06 15:42 ` [PATCH] xfrm: " Geliang Tang
  2017-05-06 15:42 ` [PATCH] yam: " Geliang Tang
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Kalle Valo, Colin Ian King
  Cc: Geliang Tang, linux-wireless, netdev, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/net/wireless/ti/wlcore/debugfs.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/drivers/net/wireless/ti/wlcore/debugfs.c b/drivers/net/wireless/ti/wlcore/debugfs.c
index de7e2a5..a2cb408 100644
--- a/drivers/net/wireless/ti/wlcore/debugfs.c
+++ b/drivers/net/wireless/ti/wlcore/debugfs.c
@@ -1149,15 +1149,9 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 	part.mem.start = *ppos;
 	part.mem.size = bytes;
 
-	buf = kmalloc(bytes, GFP_KERNEL);
-	if (!buf)
-		return -ENOMEM;
-
-	ret = copy_from_user(buf, user_buf, bytes);
-	if (ret) {
-		ret = -EFAULT;
-		goto err_out;
-	}
+	buf = memdup_user(user_buf, bytes);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
 
 	mutex_lock(&wl->mutex);
 
@@ -1197,7 +1191,6 @@ static ssize_t dev_mem_write(struct file *file, const char __user *user_buf,
 	if (ret == 0)
 		*ppos += bytes;
 
-err_out:
 	kfree(buf);
 
 	return ((ret == 0) ? bytes : ret);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] xfrm: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
                   ` (4 preceding siblings ...)
  2017-05-06 15:42 ` [PATCH] wlcore: " Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-16  9:30   ` Steffen Klassert
  2017-05-06 15:42 ` [PATCH] yam: " Geliang Tang
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Steffen Klassert, Herbert Xu, David S. Miller
  Cc: Geliang Tang, netdev, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 net/xfrm/xfrm_state.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c
index fc3c5aa..5780cda 100644
--- a/net/xfrm/xfrm_state.c
+++ b/net/xfrm/xfrm_state.c
@@ -2023,13 +2023,9 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
 	if (optlen <= 0 || optlen > PAGE_SIZE)
 		return -EMSGSIZE;
 
-	data = kmalloc(optlen, GFP_KERNEL);
-	if (!data)
-		return -ENOMEM;
-
-	err = -EFAULT;
-	if (copy_from_user(data, optval, optlen))
-		goto out;
+	data = memdup_user(optval, optlen);
+	if (IS_ERR(data))
+		return PTR_ERR(data);
 
 	err = -EINVAL;
 	rcu_read_lock();
@@ -2047,7 +2043,6 @@ int xfrm_user_policy(struct sock *sk, int optname, u8 __user *optval, int optlen
 		err = 0;
 	}
 
-out:
 	kfree(data);
 	return err;
 }
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* [PATCH] yam: use memdup_user
  2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
                   ` (5 preceding siblings ...)
  2017-05-06 15:42 ` [PATCH] xfrm: " Geliang Tang
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-08 19:02   ` David Miller
  6 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-06 15:42 UTC (permalink / raw)
  To: Jean-Paul Roubelat; +Cc: Geliang Tang, linux-hams, netdev, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
 drivers/net/hamradio/yam.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c
index b6891ad..7a7c522 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;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] usb: cdc-wdm: use memdup_user
  2017-05-06 15:42 ` [PATCH] usb: cdc-wdm: use memdup_user Geliang Tang
@ 2017-05-06 17:40   ` Bjørn Mork
  2017-05-08 15:14     ` [PATCH v2] " Geliang Tang
  0 siblings, 1 reply; 18+ messages in thread
From: Bjørn Mork @ 2017-05-06 17:40 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Greg Kroah-Hartman, Oliver Neukum, linux-usb, linux-kernel

Geliang Tang <geliangtang@gmail.com> writes:

> Use memdup_user() helper instead of open-coding to simplify the code.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
> ---
>  drivers/usb/class/cdc-wdm.c | 15 +++------------
>  1 file changed, 3 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
> index 08669fe..0e4f18c 100644
> --- a/drivers/usb/class/cdc-wdm.c
> +++ b/drivers/usb/class/cdc-wdm.c
> @@ -361,17 +361,9 @@ static ssize_t wdm_write
>  	if (we < 0)
>  		return usb_translate_errors(we);
>  
> -	buf = kmalloc(count, GFP_KERNEL);
> -	if (!buf) {
> -		rv = -ENOMEM;
> -		goto outnl;
> -	}
> -
> -	r = copy_from_user(buf, buffer, count);
> -	if (r > 0) {
> -		rv = -EFAULT;
> -		goto out_free_mem;
> -	}
> +	buf = memdup_user(buffer, count);
> +	if (IS_ERR(buf))
> +		return PTR_ERR(buf);
>  
>  	/* concurrent writes and disconnect */
>  	r = mutex_lock_interruptible(&desc->wlock);
> @@ -441,7 +433,6 @@ static ssize_t wdm_write
>  
>  	usb_autopm_put_interface(desc->intf);
>  	mutex_unlock(&desc->wlock);
> -outnl:
>  	return rv < 0 ? rv : count;
>  
>  out_free_mem_pm:

Nice!

Please check this, but I believe you can simplify that last return as
well. There is no way to end up there with rv < 0 after you've removed
the label. So

  return count;

should do.


Bjørn

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] spi: spidev: use memdup_user
  2017-05-06 15:42 ` [PATCH] spi: spidev: " Geliang Tang
@ 2017-05-08  9:28   ` Geert Uytterhoeven
  2017-05-15  8:05   ` Applied "spi: spidev: use memdup_user" to the spi tree Mark Brown
  1 sibling, 0 replies; 18+ messages in thread
From: Geert Uytterhoeven @ 2017-05-08  9:28 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Mark Brown, linux-spi, linux-kernel

On Sat, May 6, 2017 at 5:42 PM, Geliang Tang <geliangtang@gmail.com> wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
>
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> --- a/drivers/spi/spidev.c
> +++ b/drivers/spi/spidev.c
> @@ -325,7 +325,6 @@ static struct spi_ioc_transfer *
>  spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
>                 unsigned *n_ioc)
>  {
> -       struct spi_ioc_transfer *ioc;
>         u32     tmp;
>
>         /* Check type, command number and direction */
> @@ -342,14 +341,7 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
>                 return NULL;
>
>         /* copy into scratch area */
> -       ioc = kmalloc(tmp, GFP_KERNEL);
> -       if (!ioc)
> -               return ERR_PTR(-ENOMEM);
> -       if (__copy_from_user(ioc, u_ioc, tmp)) {

Note that as memdup_user() calls copy_from_user(), it repeats the access_ok()
check already done by spidev_ioctl().

> -               kfree(ioc);
> -               return ERR_PTR(-EFAULT);
> -       }
> -       return ioc;
> +       return memdup_user(u_ioc, tmp);

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH v2] usb: cdc-wdm: use memdup_user
  2017-05-06 17:40   ` Bjørn Mork
@ 2017-05-08 15:14     ` Geliang Tang
  2017-05-09  7:50       ` Oliver Neukum
  0 siblings, 1 reply; 18+ messages in thread
From: Geliang Tang @ 2017-05-08 15:14 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Oliver Neukum, Bjørn Mork
  Cc: Geliang Tang, linux-usb, linux-kernel

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
---
Changes in v2:
 - return count instead of "rv < 0 ? rv : count".
---
 drivers/usb/class/cdc-wdm.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/drivers/usb/class/cdc-wdm.c b/drivers/usb/class/cdc-wdm.c
index 08669fe..8f97224 100644
--- a/drivers/usb/class/cdc-wdm.c
+++ b/drivers/usb/class/cdc-wdm.c
@@ -361,17 +361,9 @@ static ssize_t wdm_write
 	if (we < 0)
 		return usb_translate_errors(we);
 
-	buf = kmalloc(count, GFP_KERNEL);
-	if (!buf) {
-		rv = -ENOMEM;
-		goto outnl;
-	}
-
-	r = copy_from_user(buf, buffer, count);
-	if (r > 0) {
-		rv = -EFAULT;
-		goto out_free_mem;
-	}
+	buf = memdup_user(buffer, count);
+	if (IS_ERR(buf))
+		return PTR_ERR(buf);
 
 	/* concurrent writes and disconnect */
 	r = mutex_lock_interruptible(&desc->wlock);
@@ -441,8 +433,7 @@ static ssize_t wdm_write
 
 	usb_autopm_put_interface(desc->intf);
 	mutex_unlock(&desc->wlock);
-outnl:
-	return rv < 0 ? rv : count;
+	return count;
 
 out_free_mem_pm:
 	usb_autopm_put_interface(desc->intf);
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] net/hippi/rrunner: use memdup_user
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: " Geliang Tang
@ 2017-05-08 19:02   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2017-05-08 19:02 UTC (permalink / raw)
  To: geliangtang; +Cc: jes, linux-hippi, netdev, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Sat,  6 May 2017 23:42:16 +0800

> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH] yam: use memdup_user
  2017-05-06 15:42 ` [PATCH] yam: " Geliang Tang
@ 2017-05-08 19:02   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2017-05-08 19:02 UTC (permalink / raw)
  To: geliangtang; +Cc: jpr, linux-hams, netdev, linux-kernel

From: Geliang Tang <geliangtang@gmail.com>
Date: Sat,  6 May 2017 23:42:22 +0800

> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH v2] usb: cdc-wdm: use memdup_user
  2017-05-08 15:14     ` [PATCH v2] " Geliang Tang
@ 2017-05-09  7:50       ` Oliver Neukum
  0 siblings, 0 replies; 18+ messages in thread
From: Oliver Neukum @ 2017-05-09  7:50 UTC (permalink / raw)
  To: Geliang Tang, Greg Kroah-Hartman, Bjørn Mork; +Cc: linux-kernel, linux-usb

Am Montag, den 08.05.2017, 23:14 +0800 schrieb Geliang Tang:
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Acked-by: Oliver Neukum <oneukum@suse.com>

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Applied "spi: spidev: use memdup_user" to the spi tree
  2017-05-06 15:42 ` [PATCH] spi: spidev: " Geliang Tang
  2017-05-08  9:28   ` Geert Uytterhoeven
@ 2017-05-15  8:05   ` Mark Brown
  1 sibling, 0 replies; 18+ messages in thread
From: Mark Brown @ 2017-05-15  8:05 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Mark Brown, Mark Brown, linux-spi, linux-kernel, linux-spi

The patch

   spi: spidev: use memdup_user

has been applied to the spi tree at

   git://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From f7929436a286ca31f0365a7013de968017f76818 Mon Sep 17 00:00:00 2001
From: Geliang Tang <geliangtang@gmail.com>
Date: Sat, 6 May 2017 23:42:17 +0800
Subject: [PATCH] spi: spidev: use memdup_user

Use memdup_user() helper instead of open-coding to simplify the code.

Signed-off-by: Geliang Tang <geliangtang@gmail.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 drivers/spi/spidev.c | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/spi/spidev.c b/drivers/spi/spidev.c
index 3b570018705c..d4d2d8d9f3e7 100644
--- a/drivers/spi/spidev.c
+++ b/drivers/spi/spidev.c
@@ -324,7 +324,6 @@ static struct spi_ioc_transfer *
 spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
 		unsigned *n_ioc)
 {
-	struct spi_ioc_transfer	*ioc;
 	u32	tmp;
 
 	/* Check type, command number and direction */
@@ -341,14 +340,7 @@ spidev_get_ioc_message(unsigned int cmd, struct spi_ioc_transfer __user *u_ioc,
 		return NULL;
 
 	/* copy into scratch area */
-	ioc = kmalloc(tmp, GFP_KERNEL);
-	if (!ioc)
-		return ERR_PTR(-ENOMEM);
-	if (__copy_from_user(ioc, u_ioc, tmp)) {
-		kfree(ioc);
-		return ERR_PTR(-EFAULT);
-	}
-	return ioc;
+	return memdup_user(u_ioc, tmp);
 }
 
 static long
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 18+ messages in thread

* Re: [PATCH] xfrm: use memdup_user
  2017-05-06 15:42 ` [PATCH] xfrm: " Geliang Tang
@ 2017-05-16  9:30   ` Steffen Klassert
  0 siblings, 0 replies; 18+ messages in thread
From: Steffen Klassert @ 2017-05-16  9:30 UTC (permalink / raw)
  To: Geliang Tang; +Cc: Herbert Xu, David S. Miller, netdev, linux-kernel

On Sat, May 06, 2017 at 11:42:21PM +0800, Geliang Tang wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Applied to ipsec-next, thanks!

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: wlcore: use memdup_user
  2017-05-06 15:42 ` [PATCH] wlcore: " Geliang Tang
@ 2017-05-18 13:41   ` Kalle Valo
  0 siblings, 0 replies; 18+ messages in thread
From: Kalle Valo @ 2017-05-18 13:41 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Colin Ian King, Geliang Tang, linux-wireless, netdev, linux-kernel

Geliang Tang <geliangtang@gmail.com> wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Patch applied to wireless-drivers-next.git, thanks.

6a01d48d47c8 wlcore: use memdup_user

-- 
https://patchwork.kernel.org/patch/9715005/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: wil6210: use memdup_user
  2017-05-06 15:42 ` [PATCH] wil6210: " Geliang Tang
@ 2017-05-19  7:55   ` Kalle Valo
  0 siblings, 0 replies; 18+ messages in thread
From: Kalle Valo @ 2017-05-19  7:55 UTC (permalink / raw)
  To: Geliang Tang
  Cc: Maya Erez, Kalle Valo, Geliang Tang, linux-wireless, wil6210,
	netdev, linux-kernel

Geliang Tang <geliangtang@gmail.com> wrote:
> Use memdup_user() helper instead of open-coding to simplify the code.
> 
> Signed-off-by: Geliang Tang <geliangtang@gmail.com>

Patch applied to ath-next branch of ath.git, thanks.

9a49290919e1 wil6210: use memdup_user

-- 
https://patchwork.kernel.org/patch/9715009/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2017-05-19  7:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-06 15:42 [PATCH] agp: use memdup_user Geliang Tang
2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: " Geliang Tang
2017-05-08 19:02   ` David Miller
2017-05-06 15:42 ` [PATCH] spi: spidev: " Geliang Tang
2017-05-08  9:28   ` Geert Uytterhoeven
2017-05-15  8:05   ` Applied "spi: spidev: use memdup_user" to the spi tree Mark Brown
2017-05-06 15:42 ` [PATCH] usb: cdc-wdm: use memdup_user Geliang Tang
2017-05-06 17:40   ` Bjørn Mork
2017-05-08 15:14     ` [PATCH v2] " Geliang Tang
2017-05-09  7:50       ` Oliver Neukum
2017-05-06 15:42 ` [PATCH] wil6210: " Geliang Tang
2017-05-19  7:55   ` Kalle Valo
2017-05-06 15:42 ` [PATCH] wlcore: " Geliang Tang
2017-05-18 13:41   ` Kalle Valo
2017-05-06 15:42 ` [PATCH] xfrm: " Geliang Tang
2017-05-16  9:30   ` Steffen Klassert
2017-05-06 15:42 ` [PATCH] yam: " Geliang Tang
2017-05-08 19:02   ` 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).