Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753017AbbFXNVG (ORCPT ); Wed, 24 Jun 2015 09:21:06 -0400 Received: from mout.web.de ([212.227.15.14]:62521 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751831AbbFXNU4 (ORCPT ); Wed, 24 Jun 2015 09:20:56 -0400 Message-ID: <558AAEAF.7040606@users.sourceforge.net> Date: Wed, 24 Jun 2015 15:20:47 +0200 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: David Howells , James Morris , "Serge E. Hallyn" , keyrings@linux-nfs.org, linux-security-module@vger.kernel.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH] keys: Delete an unnecessary check before the function call "key_put" References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <546BB427.2050101@users.sourceforge.net> In-Reply-To: <546BB427.2050101@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:sVNe2dhNWCZ2v+HcoTravj7brbsiVag2XaizOUBw5qwJn1rJwC0 1RSwp7/FuVMsJkVLr4ToATpU0M/BAHsrCq2JvsN/xXS9aGsY753FDxRzrz9986m0JKwJCu0 PpBE7OsYpbV9kwY41iwtyHC9S8JdnMmgIl458IIOpRX3BoD2EOA5BlDaCCBXxz0oaxqyNKw wxnVUyJsIkA10REgQi4vA== X-UI-Out-Filterresults: notjunk:1;V01:K0:GVv5059SFjA=:3fFA4QjXHeijrD8nCl6Xih h0HCceJX8nNPobyAgHzVXTyM6pl7jU15V4C91Nu1lanJFr5XSvoDhAbH8T2/5W9ph2fjBIsl1 aDTebmDD1lNvZr1jfQdlOkbVh21vJm34FRNuzNQj3iBmSlcf8jjfRLjlgzvyDkz2EMSuzK+FO 8lkfPbe7FontcddmE7rlbtdPDkmvo9YpHwLD6GFv9fZj433jck/xVin982L9f2rC6unHtFdi/ kuxYxPoxHx1+ioxVYz14Sdl66HTbOTetnsBmaTD6HR6t+hSqz11zDuGkWiIALi2Ocnzs1v2/S FILhGR5xOzvccAMy6lX5RaOKUBvkuA26L4PBv74CWKIkwhoGfaUOeDW/Xsf8qGUw3oKydIGUm 1oeBeEZrLRB0ZVHtiC95WNQ88jXIeyeGWf222p+hEG2OBR+k+X176I1Dvbr0VCvsMSwXd1nyh XTQ0ydgAl38Ob2iuK/PPqi7zV1DcISa4NZ1dQtUdffFJKWOwZLfWJFJE3tVnxNU8XaXJbVHV0 dtJTJEauM+dBGmKmffKXdPb89rVtGb/frhfR5LtLnwq17s+Hv1UgtcfIPi0ZeEnsWMWpeQteH zMaJmiaHx0bqzoJH/3t6FOa4uIVAdDQnGYOssN32K9d5p2V+JQm6iYuUjOgAcbxOiZeaH7Jy6 A8G6djzTNT4WEVEgGgwnX+r1ECnTtloC5W1oI2jEfNBp0XLpifD0UxfqPVGMnkqIST5I= Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1114 Lines: 36 From: Markus Elfring Date: Wed, 24 Jun 2015 15:16:35 +0200 The key_put() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- security/keys/process_keys.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c index bd536cb..225dd08 100644 --- a/security/keys/process_keys.c +++ b/security/keys/process_keys.c @@ -242,9 +242,7 @@ int install_session_keyring_to_cred(struct cred *cred, struct key *keyring) old = cred->session_keyring; rcu_assign_pointer(cred->session_keyring, keyring); - if (old) - key_put(old); - + key_put(old); return 0; } -- 2.4.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/