]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
selinux: Fix error return code in sel_ib_pkey_sid_slow()
authorChen Zhou <chenzhou10@huawei.com>
Thu, 12 Nov 2020 13:53:32 +0000 (21:53 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Thu, 10 Dec 2020 11:06:37 +0000 (12:06 +0100)
BugLink: https://bugs.launchpad.net/bugs/1905618
commit c350f8bea271782e2733419bd2ab9bf4ec2051ef upstream.

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.

Cc: stable@vger.kernel.org
Fixes: 409dcf31538a ("selinux: Add a cache for quicker retreival of PKey SIDs")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Chen Zhou <chenzhou10@huawei.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
security/selinux/ibpkey.c

index de92365e4324b6e1344fdcff6e758c158c9f7b0a..5887bff50560a72f4fd094f9e708b8561d68f29c 100644 (file)
@@ -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;