From patchwork Sun Jan 15 15:32:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9517557 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 C2FB6601DA for ; Sun, 15 Jan 2017 15:32:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B448028387 for ; Sun, 15 Jan 2017 15:32:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A784D283AC; Sun, 15 Jan 2017 15:32:20 +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 5940A28387 for ; Sun, 15 Jan 2017 15:32:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751268AbdAOPcT (ORCPT ); Sun, 15 Jan 2017 10:32:19 -0500 Received: from mout.web.de ([212.227.15.4]:56016 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751129AbdAOPcS (ORCPT ); Sun, 15 Jan 2017 10:32: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 0MDxFv-1cDgU61mlb-00HMq9; Sun, 15 Jan 2017 16:32:05 +0100 Subject: [PATCH 32/46] selinux: Return directly after a failed kzalloc() in class_read() 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: <6ceee0fa-a0ab-fe42-4213-f7985031ddfa@users.sourceforge.net> Date: Sun, 15 Jan 2017 16:32:03 +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:vtzcMOG6o4E4cKM4iT1YRuAjpz+X1jajPm6xM3lCub8Z226h1OX 7+MKnff9ZQYQQLEFQbYbClp6BApn6r4cRjJ+Ah8IzSOpK/aPRROudr/tKs4x1rK+JEa2tac Vcg8mJvreG6Cqbof/doSSRzv7p4aVxCMnqauF15rRFJVUCxZMJkVTRd1CHQh1ODTBcl6tFv TmsoNab60X7Xfx71wpadw== X-UI-Out-Filterresults: notjunk:1; V01:K0:wmryJJ2TjHs=:RsvDe270b4mRzWsj2URyBF eMYX8nommtA//DzghqapJKZdy8px43qxIf3gQNmufIVMi9C2SEf6QdeGItwZ5EdHbKiNAHcZs i+XOw3MTm6yuFqGTc8dMXAkTmweH8j3HfrFBFC4sPrLb4d2P8vedsiQsWFAv1zhTh+9lYKhkF aIFpEKi3DjYAzmXYDnILKIYhfmdDti4jaBRextfRgmOoNlSW+C+qiu6doM08S3C6oUXXl7pTu NIBBxpDKxMFcZ4/JRNvEHc6QeHx6nfqeVe2t9pNgBsitQYYGxgf9I7jZ2obvlr4EnSHrB94Ol CkK2AxSfZWp9HenUaczW+7rBjtKdFE4wEP654nvoVX/IQPvVe0G6QSQKqS9k3NzmRCzUmOj3Z Ezgrmt38lJ8HVlBmW3YS0wO1hDWwZCNdDzOoWDfHHmF1gUcD2PqW4LHnBvkM2TJ+K1YsSs/UZ Kt3JId4Sw6VjvxhVAbzqc+xy8KvAvsmv9OBfYZ4Dfa1oSkn4QHELoMczAs+LLNDn5CZFElHyk rz3myImLIEarz5NPl5g7asoJYZsDEKBhzxLjZjMYKBb5FTIzTR3N2LElwUQsinZLz8ok4QD2P mX4hTKsLr1eo6VSvH9IpIJ0DRymXrzKP25xIjPlSmtzSzUFKJk8GVMKLzwepUeHB55nTdh2be lmyqdL5v1NHUPJLtXecPrimBw2dAUgapboNUF2dp8qUlIx1hY8XR4RL0SAocSHgy77aXq0K2N ZIjObANudSW6tuRBM9dFKLpBVSDr3ySb2Tt81TSPwKx7/H+GpJU0ONbTYqm5BHcFbz2AbcGiW AkklI/m Sender: owner-linux-security-module@vger.kernel.org Precedence: bulk List-ID: X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 14 Jan 2017 22:30:51 +0100 Return directly after a call of the function "kzalloc" failed at the beginning. Signed-off-by: Markus Elfring --- security/selinux/ss/policydb.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/security/selinux/ss/policydb.c b/security/selinux/ss/policydb.c index 49fc5d8990e9..3af2b0849495 100644 --- a/security/selinux/ss/policydb.c +++ b/security/selinux/ss/policydb.c @@ -1316,10 +1316,9 @@ static int class_read(struct policydb *p, struct hashtab *h, void *fp) u32 len, len2, ncons, nel; int i, rc; - rc = -ENOMEM; cladatum = kzalloc(sizeof(*cladatum), GFP_KERNEL); if (!cladatum) - goto bad; + return -ENOMEM; rc = next_entry(buf, fp, sizeof(u32)*6); if (rc)