Skip to content

Commit

Permalink
nfc: fix potential NULL pointer deref in nfc_genl_dump_ses_done
Browse files Browse the repository at this point in the history
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: ac22ac4 ("NFC: Add a GET_SE netlink API")
Signed-off-by: Krzysztof Kozlowski <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
  • Loading branch information
krzk authored and kuba-moo committed Dec 9, 2021
1 parent fd79a0c commit 4cd8371
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/nfc/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 4cd8371

Please sign in to comment.