]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done
authorKrzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Thu, 9 Dec 2021 08:13:07 +0000 (09:13 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Tue, 4 Jan 2022 08:49:14 +0000 (09:49 +0100)
BugLink: https://bugs.launchpad.net/bugs/1954931
commit 4cd8371a234d051f9c9557fcbb1f8c523b1c0d10 upstream.

The done() netlink callback nfc_genl_dump_ses_done() should check if
received argument is non-NULL, because its allocation could fail earlier
in dumpit() (nfc_genl_dump_ses()).

Fixes: ac22ac466a65 ("NFC: Add a GET_SE netlink API")
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
Link: https://lore.kernel.org/r/20211209081307.57337-1-krzysztof.kozlowski@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
net/nfc/netlink.c

index 49089c50872e683e5b75875630f9a80f26cd7ad9..082085c25a8e406da5ded5428cb86598740c028a 100644 (file)
@@ -1392,8 +1392,10 @@ static int nfc_genl_dump_ses_done(struct netlink_callback *cb)
 {
        struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
 
-       nfc_device_iter_exit(iter);
-       kfree(iter);
+       if (iter) {
+               nfc_device_iter_exit(iter);
+               kfree(iter);
+       }
 
        return 0;
 }