Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 294316a4 authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller
Browse files

net/hippi/rrunner: use memdup_user



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

Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3bb4858f
Loading
Loading
Loading
Loading
+7 −10
Original line number Diff line number Diff line
@@ -1615,17 +1615,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){