|
@@ -328,26 +328,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
|
|
|
|
|
|
pos = *ppos;
|
|
pos = *ppos;
|
|
|
|
|
|
- if (pos != 0) {
|
|
|
|
- ret = -EINVAL;
|
|
|
|
- goto bail;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if (count != sizeof(struct qib_flash)) {
|
|
|
|
- ret = -EINVAL;
|
|
|
|
- goto bail;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- tmp = kmalloc(count, GFP_KERNEL);
|
|
|
|
- if (!tmp) {
|
|
|
|
- ret = -ENOMEM;
|
|
|
|
- goto bail;
|
|
|
|
- }
|
|
|
|
|
|
+ if (pos != 0 || count != sizeof(struct qib_flash))
|
|
|
|
+ return -EINVAL;
|
|
|
|
|
|
- if (copy_from_user(tmp, buf, count)) {
|
|
|
|
- ret = -EFAULT;
|
|
|
|
- goto bail_tmp;
|
|
|
|
- }
|
|
|
|
|
|
+ tmp = memdup_user(buf, count);
|
|
|
|
+ if (IS_ERR(tmp))
|
|
|
|
+ return PTR_ERR(tmp);
|
|
|
|
|
|
dd = private2dd(file);
|
|
dd = private2dd(file);
|
|
if (qib_eeprom_write(dd, pos, tmp, count)) {
|
|
if (qib_eeprom_write(dd, pos, tmp, count)) {
|
|
@@ -361,8 +347,6 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
|
|
|
|
|
|
bail_tmp:
|
|
bail_tmp:
|
|
kfree(tmp);
|
|
kfree(tmp);
|
|
-
|
|
|
|
-bail:
|
|
|
|
return ret;
|
|
return ret;
|
|
}
|
|
}
|
|
|
|
|