mirror of https://gitee.com/openkylin/linux.git
staging: i4l: icn: use memdup_user
Its better to use memdup_user which does the same thing which this code has implemented. Also removed a related warning as we will be warned if allocation fails. Suggested-by: Fengguang Wu <fengguang.wu@intel.com> Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
3b1d75332e
commit
b91796e86b
|
@ -810,16 +810,10 @@ icn_loadboot(u_char __user *buffer, icn_card *card)
|
||||||
#ifdef BOOT_DEBUG
|
#ifdef BOOT_DEBUG
|
||||||
printk(KERN_DEBUG "icn_loadboot called, buffaddr=%08lx\n", (ulong) buffer);
|
printk(KERN_DEBUG "icn_loadboot called, buffaddr=%08lx\n", (ulong) buffer);
|
||||||
#endif
|
#endif
|
||||||
codebuf = kmalloc(ICN_CODE_STAGE1, GFP_KERNEL);
|
codebuf = memdup_user(buffer, ICN_CODE_STAGE1);
|
||||||
if (!codebuf) {
|
if (IS_ERR(codebuf))
|
||||||
printk(KERN_WARNING "icn: Could not allocate code buffer\n");
|
return PTR_ERR(codebuf);
|
||||||
ret = -ENOMEM;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
if (copy_from_user(codebuf, buffer, ICN_CODE_STAGE1)) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
goto out_kfree;
|
|
||||||
}
|
|
||||||
if (!card->rvalid) {
|
if (!card->rvalid) {
|
||||||
if (!request_region(card->port, ICN_PORTLEN, card->regname)) {
|
if (!request_region(card->port, ICN_PORTLEN, card->regname)) {
|
||||||
printk(KERN_WARNING
|
printk(KERN_WARNING
|
||||||
|
@ -902,7 +896,6 @@ icn_loadboot(u_char __user *buffer, icn_card *card)
|
||||||
|
|
||||||
out_kfree:
|
out_kfree:
|
||||||
kfree(codebuf);
|
kfree(codebuf);
|
||||||
out:
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue