]> git.baikalelectronics.ru Git - 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)
committerJakub Kicinski <kuba@kernel.org>
Thu, 9 Dec 2021 15:50:32 +0000 (07:50 -0800)
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>
net/nfc/netlink.c

index 0b4fae183a4bc0ddf251469a1b562964ee1304e8..f184b0db79d4026418ffa4fbf80bd6b38bdd3d0a 100644 (file)
@@ -1394,8 +1394,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;
 }