linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails.
@ 2016-11-11  9:04 Sachin Shukla
  2016-11-11 20:37 ` Jens Axboe
  0 siblings, 1 reply; 2+ messages in thread
From: Sachin Shukla @ 2016-11-11  9:04 UTC (permalink / raw)
  To: Jens Axboe, Asai Thambi SP, Selvan Mani, Rajesh Kumar Sambandam,
	Vignesh Gunasekaran, Al Viro, linux-kernel, sachiniiitm
  Cc: ravikant.s2, p.shailesh, ashish.kalra, vidushi.koul

From: "Sachin Shukla" <sachin.s5@samsung.com>

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 <sachin.s5@samsung.com>
---
 drivers/block/mtip32xx/mtip32xx.c |   14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 3cfd879..68e332b 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -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,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails.
  2016-11-11  9:04 [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails Sachin Shukla
@ 2016-11-11 20:37 ` Jens Axboe
  0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2016-11-11 20:37 UTC (permalink / raw)
  To: Sachin Shukla, Asai Thambi SP, Selvan Mani,
	Rajesh Kumar Sambandam, Vignesh Gunasekaran, Al Viro,
	linux-kernel, sachiniiitm
  Cc: ravikant.s2, p.shailesh, ashish.kalra, vidushi.koul

On 11/11/2016 02:04 AM, Sachin Shukla wrote:
> From: "Sachin Shukla" <sachin.s5@samsung.com>
>
> 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.

Applied for 4.10, thanks.

-- 
Jens Axboe

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-11-11 20:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-11  9:04 [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails Sachin Shukla
2016-11-11 20:37 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).