net/hippi/rrunner: 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>
This commit is contained in:
parent
3bb4858fda
commit
294316a4af
|
@ -1615,17 +1615,14 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
|
image = memdup_user(rq->ifr_data, EEPROM_BYTES);
|
||||||
oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
|
if (IS_ERR(image))
|
||||||
if (!image || !oldimage) {
|
return PTR_ERR(image);
|
||||||
error = -ENOMEM;
|
|
||||||
goto wf_out;
|
|
||||||
}
|
|
||||||
|
|
||||||
error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
|
oldimage = kmalloc(EEPROM_BYTES, GFP_KERNEL);
|
||||||
if (error) {
|
if (!oldimage) {
|
||||||
error = -EFAULT;
|
kfree(image);
|
||||||
goto wf_out;
|
return -ENOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rrpriv->fw_running){
|
if (rrpriv->fw_running){
|
||||||
|
|
Loading…
Reference in New Issue