Skip to content

Commit

Permalink
Block: mtip32xx: Improvement in code readability when memdup_user() f…
Browse files Browse the repository at this point in the history
…ails.

There is no need to call kfree() if memdup_user() fails, as no memory
was allocated and the error in the error-valued pointer should be returned.

Signed-off-by: Sachin Shukla <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Sachin Shukla authored and axboe committed Nov 11, 2016
1 parent 066a4a7 commit b425b02
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions drivers/block/mtip32xx/mtip32xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2035,18 +2035,14 @@ static int exec_drive_taskfile(struct driver_data *dd,
taskout = req_task->out_size;
taskin = req_task->in_size;
/* 130560 = 512 * 0xFF*/
if (taskin > 130560 || taskout > 130560) {
err = -EINVAL;
goto abort;
}
if (taskin > 130560 || taskout > 130560)
return -EINVAL;

if (taskout) {
outbuf = memdup_user(buf + outtotal, taskout);
if (IS_ERR(outbuf)) {
err = PTR_ERR(outbuf);
outbuf = NULL;
goto abort;
}
if (IS_ERR(outbuf))
return PTR_ERR(outbuf);

outbuf_dma = pci_map_single(dd->pdev,
outbuf,
taskout,
Expand Down

0 comments on commit b425b02

Please sign in to comment.