]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.4/nfc-fix-potential-null-pointer-deref-in-nfc_genl_dump_ses_done.patch
4.4-stable patches
[thirdparty/kernel/stable-queue.git] / queue-4.4 / nfc-fix-potential-null-pointer-deref-in-nfc_genl_dump_ses_done.patch
1 From 4cd8371a234d051f9c9557fcbb1f8c523b1c0d10 Mon Sep 17 00:00:00 2001
2 From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
3 Date: Thu, 9 Dec 2021 09:13:07 +0100
4 Subject: nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done
5
6 From: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
7
8 commit 4cd8371a234d051f9c9557fcbb1f8c523b1c0d10 upstream.
9
10 The done() netlink callback nfc_genl_dump_ses_done() should check if
11 received argument is non-NULL, because its allocation could fail earlier
12 in dumpit() (nfc_genl_dump_ses()).
13
14 Fixes: ac22ac466a65 ("NFC: Add a GET_SE netlink API")
15 Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@canonical.com>
16 Link: https://lore.kernel.org/r/20211209081307.57337-1-krzysztof.kozlowski@canonical.com
17 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
18 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
19 ---
20 net/nfc/netlink.c | 6 ++++--
21 1 file changed, 4 insertions(+), 2 deletions(-)
22
23 --- a/net/nfc/netlink.c
24 +++ b/net/nfc/netlink.c
25 @@ -1366,8 +1366,10 @@ static int nfc_genl_dump_ses_done(struct
26 {
27 struct class_dev_iter *iter = (struct class_dev_iter *) cb->args[0];
28
29 - nfc_device_iter_exit(iter);
30 - kfree(iter);
31 + if (iter) {
32 + nfc_device_iter_exit(iter);
33 + kfree(iter);
34 + }
35
36 return 0;
37 }