Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp360240pxb; Thu, 12 Nov 2020 05:50:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9tojK7OExq9lRU8+1fuElMQb39xEelqCpmpBEDHqXm8HmQpxUcG9cUgqQBLK/oFECcXwU X-Received: by 2002:a50:ec10:: with SMTP id g16mr5416968edr.63.1605189043766; Thu, 12 Nov 2020 05:50:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605189043; cv=none; d=google.com; s=arc-20160816; b=fU3ELrytuPoxScWDAdCtmxhlwZPf0trJlbdO/6ul2v6kn6b8U2jN6XUewLxHY3rnvl 0T2Dvh8E7cdgoM0Jyp0R3CNBJ9kd0wgFAQ3t0xcEv31C8gts8kC4FzuStJuqBJNSJmCu QscAKa0Z2pluln/qIEBM7qfiS0xYr41Mibqc03YOLjvEZN07CNskwFaRPMzb5MxlIIJN ADKAtQzG2v8c9ia2m9tb8AYOnw5NelbC/oWJzvwNh8Kq4ohA73hHC2p7ZKmojDh3ZPT7 DZCP/t0xbkJ7WoVO8LveeUdLioy5OtIHYWpacoIcBz/pdHsFO39MLtmy/YDlxgCVS/39 NfAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=r3aklngBj8mKdZOMXuVeuueVn/JbWcUFmrst2JS1Ixg=; b=0dcjIh88XGY4Hg1EEr7zsHC/TI9EIGkHCiLkTVz4ibe0H5Ct9+FfhDMPAaTLw4E7ve VPedNHPVGDnIzZp+Dz9BvRUDlJhCmiglEtqxn7NXa4F97FptgHp98JhnJXOtOZqy6PqJ H2luFld8SyMUsCY8UHAQBtp5BuBxN96cYDl4XHcqQIfkqMCf3unZAsi5TzTOTlt0WkCK 06ohixbiBjSFC0MmwgKhRZQbDfxrwsHNzOSTEkbWc/IbyxUh83/LxjPRxSG8S6CX8IUL BTdY+W9OaGU1nx4L97OUotdh1SZctf1+IkSx3YhKZLQu8n32Mzrkupx84hmP9bVF2RB/ 3nwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cb12si3639548edb.272.2020.11.12.05.50.20; Thu, 12 Nov 2020 05:50:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728324AbgKLNso (ORCPT + 99 others); Thu, 12 Nov 2020 08:48:44 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7525 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727863AbgKLNsn (ORCPT ); Thu, 12 Nov 2020 08:48:43 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CX2xW1SmyzhkbY; Thu, 12 Nov 2020 21:48:31 +0800 (CST) Received: from localhost.localdomain.localdomain (10.175.113.25) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Thu, 12 Nov 2020 21:48:33 +0800 From: Chen Zhou To: , , , , CC: , , , Hulk Robot Subject: [PATCH v2] selinux: Fix error return code in sel_ib_pkey_sid_slow() Date: Thu, 12 Nov 2020 21:53:32 +0800 Message-ID: <20201112135332.89062-1-chenzhou10@huawei.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.175.113.25] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix to return a negative error code from the error handling case instead of 0 in function sel_ib_pkey_sid_slow(), as done elsewhere in this function. Fixes: 409dcf31538a ("selinux: Add a cache for quicker retreival of PKey SIDs") Reported-by: Hulk Robot Signed-off-by: Chen Zhou --- security/selinux/ibpkey.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security/selinux/ibpkey.c b/security/selinux/ibpkey.c index f68a7617cfb9..3a63a989e55e 100644 --- a/security/selinux/ibpkey.c +++ b/security/selinux/ibpkey.c @@ -151,8 +151,10 @@ static int sel_ib_pkey_sid_slow(u64 subnet_prefix, u16 pkey_num, u32 *sid) * is valid, it just won't be added to the cache. */ new = kzalloc(sizeof(*new), GFP_ATOMIC); - if (!new) + if (!new) { + ret = -ENOMEM; goto out; + } new->psec.subnet_prefix = subnet_prefix; new->psec.pkey = pkey_num; -- 2.20.1