From patchwork Fri Nov 11 08:48:40 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: 9422595 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 63978601C0 for ; Fri, 11 Nov 2016 08:51:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE4F29980 for ; Fri, 11 Nov 2016 08:51:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 508CA29982; Fri, 11 Nov 2016 08:51:22 +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 DAFA029980 for ; Fri, 11 Nov 2016 08:51:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965927AbcKKIvB (ORCPT ); Fri, 11 Nov 2016 03:51:01 -0500 Received: from mailout2.samsung.com ([203.254.224.25]:49143 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965910AbcKKIu7 (ORCPT ); Fri, 11 Nov 2016 03:50:59 -0500 Received: from epcpsbgm2new.samsung.com (epcpsbgm2 [203.254.230.27]) by mailout2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OGG02DNDZ8W9X20@mailout2.samsung.com>; Fri, 11 Nov 2016 17:50:56 +0900 (KST) X-AuditID: cbfee61b-f796f6d000004092-cd-582586701783 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm2new.samsung.com (EPCPMTA) with SMTP id 57.30.16530.07685285; Fri, 11 Nov 2016 17:50:56 +0900 (KST) Received: from localhost.localdomain ([107.108.168.37]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OGG00D3BZ8M6V40@mmp1.samsung.com>; Fri, 11 Nov 2016 17:50:56 +0900 (KST) From: Shailendra Verma To: Paul Moore , Stephen Smalley , Eric Paris , James Morris , "Serge E. Hallyn" , selinux@tycho.nsa.gov, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, Shailendra Verma , Shailendra Verma Cc: vidushi.koul@samsung.com Subject: [PATCH] Security: selinux - Improvement in code readability when Date: Fri, 11 Nov 2016 14:18:40 +0530 Message-id: <1478854120-25311-1-git-send-email-shailendra.v@samsung.com> X-Mailer: git-send-email 1.7.9.5 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrCLMWRmVeSWpSXmKPExsVy+t9jAd2CNtUIgz+PBS06H55ltuh7HGRx edccNosPPY/YLG5Pms5icXj3YmaLyU8OsVicv3CO3eLWvJlsFou+vWK2+HvxEpsDt8fOWXfZ Pa7tjvT4+PQWi8fZr1Eea/e+YPTo27KK0WPr9P+sHp83yQVwRLnZZKQmpqQWKaTmJeenZOal 2yqFhrjpWigp5CXmptoqRej6hgQpKZQl5pQCeUYGaMDBOcA9WEnfLsEt4/qLtewFCzkqzj7a w97AeIeti5GTQ0LARGL2iovsELaYxIV764HiXBxCAksZJS7PfA7l/GSUeLJ4IQtIFZuAocTr vr9MIAkRgWZmiZu9PWAJZgEZiX0T25hAbGEBT4lb12+DjWURUJW4sP0hcxcjBwevgIfEvUUV IKaEgILEnEk2Exi5FzAyrGKUSC1ILihOSs81ykst1ytOzC0uzUvXS87P3cQIDvFn0jsYD+9y P8QowMGoxMMrkaUaIcSaWFZcmXuIUYKDWUmEt6UVKMSbklhZlVqUH19UmpNafIjRFGj9RGYp 0eR8YPzllcQbmpibmBsbWJhbWpoYKYnzNs5+Fi4kkJ5YkpqdmlqQWgTTx8TBKdXAmMZbNiV3 u2/ZZcugrzVvqr93FX0JLJBic5c++5OzgE2QwXd66r6dkzz3MtTfnpFdW1XuJ/b+p7y9I18M 17N7czsfeFnPPbcx4hqP0M72dP5XWyJ4tzUwh2ZZrjo24fnzzPXRJhWtQvNfv6mce1I98+2/ mAW7Ez7v603M2+T6xOuAYpeN7akDSizFGYmGWsxFxYkAlAmDCocCAAA= X-MTR: 20000000000000000@CPGS Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: 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 --- security/selinux/selinuxfs.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index 72c145d..b6d0a23 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c @@ -1166,7 +1166,7 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf, length = -EINVAL; if (sscanf(page, "%d", &new_value) != 1) - goto out; + goto out1; if (new_value) new_value = 1; @@ -1174,9 +1174,10 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf, bool_pending_values[index] = new_value; length = count; +out1: + kfree(page); out: mutex_unlock(&sel_mutex); - kfree(page); return length; }