diff options
Diffstat (limited to 'drivers/infiniband/hw/qib/qib_fs.c')
-rw-r--r-- | drivers/infiniband/hw/qib/qib_fs.c | 26 |
1 files changed, 5 insertions, 21 deletions
diff --git a/drivers/infiniband/hw/qib/qib_fs.c b/drivers/infiniband/hw/qib/qib_fs.c index fcdf37913a26..c3edc033f7c4 100644 --- a/drivers/infiniband/hw/qib/qib_fs.c +++ b/drivers/infiniband/hw/qib/qib_fs.c | |||
@@ -328,26 +328,12 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
328 | 328 | ||
329 | pos = *ppos; | 329 | pos = *ppos; |
330 | 330 | ||
331 | if (pos != 0) { | 331 | if (pos != 0 || count != sizeof(struct qib_flash)) |
332 | ret = -EINVAL; | 332 | return -EINVAL; |
333 | goto bail; | ||
334 | } | ||
335 | |||
336 | if (count != sizeof(struct qib_flash)) { | ||
337 | ret = -EINVAL; | ||
338 | goto bail; | ||
339 | } | ||
340 | |||
341 | tmp = kmalloc(count, GFP_KERNEL); | ||
342 | if (!tmp) { | ||
343 | ret = -ENOMEM; | ||
344 | goto bail; | ||
345 | } | ||
346 | 333 | ||
347 | if (copy_from_user(tmp, buf, count)) { | 334 | tmp = memdup_user(buf, count); |
348 | ret = -EFAULT; | 335 | if (IS_ERR(tmp)) |
349 | goto bail_tmp; | 336 | return PTR_ERR(tmp); |
350 | } | ||
351 | 337 | ||
352 | dd = private2dd(file); | 338 | dd = private2dd(file); |
353 | if (qib_eeprom_write(dd, pos, tmp, count)) { | 339 | if (qib_eeprom_write(dd, pos, tmp, count)) { |
@@ -361,8 +347,6 @@ static ssize_t flash_write(struct file *file, const char __user *buf, | |||
361 | 347 | ||
362 | bail_tmp: | 348 | bail_tmp: |
363 | kfree(tmp); | 349 | kfree(tmp); |
364 | |||
365 | bail: | ||
366 | return ret; | 350 | return ret; |
367 | } | 351 | } |
368 | 352 | ||