Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965547AbcKKJHW (ORCPT ); Fri, 11 Nov 2016 04:07:22 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:54126 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S936249AbcKKJHR (ORCPT ); Fri, 11 Nov 2016 04:07:17 -0500 X-AuditID: cbfee61a-f79916d0000062de-5a-58258a43b970 From: Sachin Shukla To: Jens Axboe , Asai Thambi SP , Selvan Mani , Rajesh Kumar Sambandam , Vignesh Gunasekaran , Al Viro , linux-kernel@vger.kernel.org, sachiniiitm@gmail.com Cc: ravikant.s2@samsung.com, p.shailesh@samsung.com, ashish.kalra@samsung.com, vidushi.koul@samsung.com Subject: [PATCH] Block: mtip32xx: Improvement in code readability when memdup_user() fails. Date: Fri, 11 Nov 2016 14:34:51 +0530 Message-id: <1478855091-26096-1-git-send-email-sachin.s5@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRmVeSWpSXmKPExsVy+t9jAV3nLtUIg89v+CzWtsxis7g/7Ru7 xf89x9gsLu+aw2axY0ori0VTw2x2i69LdzFZPFg0l9li7t/5rBZtuzYzWfy9eInN4vzf46wO PB4Tm9+xe+ycdZfd4/v6DjaPvi2rGD0+b5Lz2PTkLVMAW5SbTUZqYkpqkUJqXnJ+SmZeuq1S aIibroWSQl5ibqqtUoSub0iQkkJZYk4pkGdkgAYcnAPcg5X07RLcMjpv1BVs5qx4eOY4SwPj QfYuRk4OCQETiVWNncwQtpjEhXvr2boYuTiEBJYySjTMecIE4fxklGj5vokFpIpNQFviQ/98 FpCEiMAKJonOvadZuxg5OJgFMiVaGipAaoQFYiV2LH4AVs8ioCpx9OsJsG28Aq4Sj6ZuZAYp lxBQkJgzyWYCI/cCRoZVjBKpBckFxUnpuYZ5qeV6xYm5xaV56XrJ+bmbGMHB/UxqB+PBXe6H GAU4GJV4eCWyVCOEWBPLiitzDzFKcDArifC2tAKFeFMSK6tSi/Lji0pzUosPMZoC7Z/ILCWa nA+MvLySeEMTcxNzYwMLc0tLEyMlcd7G2c/ChQTSE0tSs1NTC1KLYPqYODilGhjrA60qbBRl fs47HeG3vqteeB/HvXI5rSUd5vp7rXPy3DPzJiye+vCDgNMHkZIfgsa86V/OmC5x7FQqO1FZ UB3bEiymETV/ubCm+GF2t6afZycbLXhnIbTY627jAhbFKxsiotO47N5dWvNLV+TLpizZx0LP nFztv5uf07DdOfXoFPm9J34/DVViKc5INNRiLipOBADEmH2rhAIAAA== X-MTR: 20000000000000000@CPGS Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1161 Lines: 40 From: "Sachin Shukla" 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 --- 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