From patchwork Thu Nov 10 09:47:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: shailendra.v@samsung.com X-Patchwork-Id: 9420863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A80CE601C0 for ; Thu, 10 Nov 2016 09:50:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AA86E29601 for ; Thu, 10 Nov 2016 09:50:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F29529606; Thu, 10 Nov 2016 09:50:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 20F7029601 for ; Thu, 10 Nov 2016 09:50:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754509AbcKJJuC (ORCPT ); Thu, 10 Nov 2016 04:50:02 -0500 Received: from mailout4.samsung.com ([203.254.224.34]:43209 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753008AbcKJJuB (ORCPT ); Thu, 10 Nov 2016 04:50:01 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout4.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGF0239G7BAUID0@mailout4.samsung.com>; Thu, 10 Nov 2016 18:49:58 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-83-582442c67eea Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 5A.31.16530.6C244285; Thu, 10 Nov 2016 18:49:58 +0900 (KST) Received: from localhost.localdomain ([107.108.168.37]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGF00KLX7AY8570@mmp2.samsung.com>; Thu, 10 Nov 2016 18:49:58 +0900 (KST) From: Shailendra Verma To: Chris Mason , Josef Bacik , David Sterba , linux-btrfs@vger.kernel.org, Shailendra Verma , Shailendra Verma Cc: linux-kernel@vger.kernel.org, vidushi.koul@samsung.com Subject: [PATCH] Fs: Btrfs - Improvement in code readability when Date: Thu, 10 Nov 2016 15:17:41 +0530 Message-id: <1478771261-1020-1-git-send-email-shailendra.v@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrJLMWRmVeSWpSXmKPExsVy+t9jQd1jTioRBr+PaVpM6p/BbnHhRyOT xd+dC1ksLj1ewW5xedccNotb82ayWSz69orZ4u/FS2wOHB4Tm9+xe+ycdZfdo2/LKkaP9Vuu snh83iQXwBrlZpORmpiSWqSQmpecn5KZl26rFBripmuhpJCXmJtqqxSh6xsSpKRQlphTCuQZ GaABB+cA92AlfbsEt4y9x/6xFTTwVCx8upOlgfEUZxcjJ4eEgInEmquPWCBsMYkL99azdTFy cQgJzGKUWL5jITOE85NRov/fSzaQKjYBQ4nXfX+ZQGwRgbuMEgcf+4HYzAJWEpP+z2YFsYUF HCU+z5oAZrMIqEq8ONsKVs8r4C7x+lEP0DYOoG0KEnMm2Uxg5F7AyLCKUSK1ILmgOCk91ygv tVyvODG3uDQvXS85P3cTIzhYn0nvYDy8y/0QowAHoxIPr0WlcoQQa2JZcWXuIUYJDmYlEV5V R5UIId6UxMqq1KL8+KLSnNTiQ4ymQPsnMkuJJucDIymvJN7QxNzE3NjAwtzS0sRISZy3cfaz cCGB9MSS1OzU1ILUIpg+Jg5OqQZGpSL/D7p3VzZsfjHLZJ3/0dvJYR/XB9lnmOU0r9g1/+03 D+3VTy57qO65FNcfLfqX99X8A90dXvp/b9/MWfjkxcQLK57ZBrAs0ZeRNJ2wJ/r5pYuWXM8n srN9OiQ1pffj+eKnu7SnnQuUFG+avbfxZkLkjvU8xZ1TMxrO/2j84J1q0iDyJOTSIiWW4oxE Qy3mouJEAIE0CtFsAgAA X-MTR: 20000000000000000@CPGS Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Shailendra Verma" 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: Shailendra Verma --- fs/btrfs/ioctl.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 18e1aa0f..fddbc04 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -4567,11 +4567,8 @@ static long btrfs_ioctl_logical_to_ino(struct btrfs_root *root, return -EPERM; loi = memdup_user(arg, sizeof(*loi)); - if (IS_ERR(loi)) { - ret = PTR_ERR(loi); - loi = NULL; - goto out; - } + if (IS_ERR(loi)) + return PTR_ERR(loi); path = btrfs_alloc_path(); if (!path) { @@ -5198,11 +5195,8 @@ static long btrfs_ioctl_set_received_subvol_32(struct file *file, int ret = 0; args32 = memdup_user(arg, sizeof(*args32)); - if (IS_ERR(args32)) { - ret = PTR_ERR(args32); - args32 = NULL; - goto out; - } + if (IS_ERR(args32)) + return PTR_ERR(args32); args64 = kmalloc(sizeof(*args64), GFP_KERNEL); if (!args64) { @@ -5250,11 +5244,8 @@ static long btrfs_ioctl_set_received_subvol(struct file *file, int ret = 0; sa = memdup_user(arg, sizeof(*sa)); - if (IS_ERR(sa)) { - ret = PTR_ERR(sa); - sa = NULL; - goto out; - } + if (IS_ERR(sa)) + return PTR_ERR(sa); ret = _btrfs_ioctl_set_received_subvol(file, sa);