Skip to contentSkip to conversation

nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done

PATCH Applied Krzysztof Kozlowski 2 participants 2 messages Dec 9, 2021

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done

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")
---
 net/nfc/netlink.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
net/nfc/netlink.c +4 -2
index 334f63c9529e..5c706ed75b33 100644
@@ -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;
 }
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 9 Dec 2021 09:13:07 +0100 you wrote:

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")

[...]

Here is the summary with links:
- nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done

    https://git.kernel.org/netdev/net/c/fd79a0cbf0b2

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html