netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/hippi/rrunner: use memdup_user
       [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
@ 2017-05-06 15:42 ` Geliang Tang
  2017-05-08 19:02   ` David Miller
  2017-05-06 15:42 ` [PATCH] wil6210: " Geliang Tang
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 10+ 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] 10+ messages in thread

* [PATCH] wil6210: use memdup_user
       [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: 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)
  4 siblings, 1 reply; 10+ 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] 10+ messages in thread

* [PATCH] wlcore: use memdup_user
       [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: use memdup_user Geliang Tang
  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
  4 siblings, 1 reply; 10+ 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] 10+ messages in thread

* [PATCH] xfrm: use memdup_user
       [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
                   ` (2 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
  4 siblings, 1 reply; 10+ 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] 10+ messages in thread

* [PATCH] yam: use memdup_user
       [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
                   ` (3 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
  4 siblings, 1 reply; 10+ 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] 10+ messages in thread

* Re: [PATCH] net/hippi/rrunner: use memdup_user
  2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: use memdup_user Geliang Tang
@ 2017-05-08 19:02   ` David Miller
  0 siblings, 0 replies; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ 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; 10+ 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] 10+ messages in thread

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

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <df8091d4c64a0d5a7ab0a5989f34552a5eebd15e.1493778999.git.geliangtang@gmail.com>
2017-05-06 15:42 ` [PATCH] net/hippi/rrunner: use memdup_user Geliang Tang
2017-05-08 19:02   ` David Miller
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).