From patchwork Sun Jan 15 15:44:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9517615 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 250DF60210 for ; Sun, 15 Jan 2017 15:52:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47F7128428 for ; Sun, 15 Jan 2017 15:44:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3AB662849A; Sun, 15 Jan 2017 15:44:46 +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 BA13528428 for ; Sun, 15 Jan 2017 15:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751284AbdAOPoT (ORCPT ); Sun, 15 Jan 2017 10:44:19 -0500 Received: from mout.web.de ([212.227.15.4]:49876 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751098AbdAOPoS (ORCPT ); Sun, 15 Jan 2017 10:44:18 -0500 Received: from [192.168.1.2] ([78.49.147.199]) by smtp.web.de (mrweb003 [213.165.67.108]) with ESMTPSA (Nemesis) id 0M2uXO-1cksHw0IIY-00sfmB; Sun, 15 Jan 2017 16:44:06 +0100 Subject: [PATCH 44/46] selinux: Adjust two checks for null pointers To: linux-security-module@vger.kernel.org, selinux@tycho.nsa.gov, Eric Paris , James Morris , Paul Moore , "Serge E. Hallyn" , Stephen Smalley , William Roberts References: Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Message-ID: Date: Sun, 15 Jan 2017 16:44:04 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 MIME-Version: 1.0 In-Reply-To: X-Provags-ID: V03:K0:JBLBeLHU2rqTBU29HM3euneW4DtQLIuV98fy+oFQ9G742tRf/Ba xCTlDbzASEcCgivydXNlbyURJLRnh4PRuVobx17dw8FWLUrHX+Vra9BubJwHFU07dh75jF8 tqdmNlDjQmHItXvo4f3mizQeBTI5nX/+7oI5VVjPeeU4KO/iwWrhqw8xWp3zljsIlmYbwrT kmamNfAGqRt1SptShQB/A== X-UI-Out-Filterresults: notjunk:1; V01:K0:RFhlbeHFDgU=:xpMhzScqGBLzM5U6atsMRE WD1gcUpS+OKQUVNO02eErL79bHBmIeh/NYCsGDGHXJ6LKnatWgnYoAgkQN1DHNm64ESgT1qwn eFIR1YOQ917Cw9GI+Vkzc35hSwfqnnnKStc3ttCIJnwaPMvyl3uOJflcU73Rs6RllrGRTna8E 6j6EHLh1YARrjUMK3i3fEZ1c9X91mr0dWgcX0lHtpsfYD37Td4nkt5Z8qABBuQssElu890ziw O59xJodPFJgsC7Is3D0syBIabSC6QZxPmtRTKEaj7vVlMf45aREAja0j0JbUCi7ZJKheE9jET yICu13volsqUO80Wj6bpQEJS1otBrE9u+vBDt+HPxw5oKpfso6Z1MewrM1X28b8dn+OSygfm+ DC1EDX71X/r9yVdyHNWeiaA3plUmWa3IlWFaPkoDSoz3gTBKo82eBTIPhgN7/9/sHRGvChFeK 74zZ53I0FLrm3m6EgifmLVo3wynpxUXtbOWVHNMxrceGG6Z5DpZ4GzHc5WvHV5ojkAn23fMYs diUlKGbiEmSCRobqBtIoqOCGGC+3zJJE+Nn9cdSj0mZsIPmTQOO4cVHGh+zFH8BCXBKmwSDfZ am3A+X2XCiypUHgLIPWQ1GSLieQlShUTj/DOlJCSes8o95v2EzaFXfTr2NqdpfUuACILOXPuY hlj3ndYy3R4mk4i3VQ8e1SBBFtyzT5C4CaryLIFWZGJfn+aI9NTcYhccz7FgtIvEJ50aeUyl1 HJqhyUdMZMKhkQ82gl+LPHLZ5XUqLS4LbLEZKSq/emLWP6t4cZcwpDESLwPFOcdYnJyC7F61s LkcKXdK Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sun, 15 Jan 2017 13:30:20 +0100 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The script "checkpatch.pl" pointed information out like the following. Comparison to NULL could be written !… Thus fix affected source code places. Signed-off-by: Markus Elfring --- security/selinux/ss/sidtab.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c index c9533b21942b..f6915f257486 100644 --- a/security/selinux/ss/sidtab.c +++ b/security/selinux/ss/sidtab.c @@ -54,7 +54,7 @@ int sidtab_insert(struct sidtab *s, u32 sid, struct context *context) } newnode = kmalloc(sizeof(*newnode), GFP_ATOMIC); - if (newnode == NULL) { + if (!newnode) { rc = -ENOMEM; goto out; } @@ -98,7 +98,7 @@ static struct context *sidtab_search_core(struct sidtab *s, u32 sid, int force) if (force && cur && sid == cur->sid && cur->context.len) return &cur->context; - if (cur == NULL || sid != cur->sid || cur->context.len) { + if (!cur || sid != cur->sid || cur->context.len) { /* Remap invalid SIDs to the unlabeled SID. */ sid = SECINITSID_UNLABELED; hvalue = SIDTAB_HASH(sid);