[PATCH 4.14 28/30] NFC: fix possible resource leak

From: Greg Kroah-Hartman
Date: Tue Feb 02 2021 - 09:21:38 EST


From: Pan Bian <bianpan2016@xxxxxxx>

commit d8f923c3ab96dbbb4e3c22d1afc1dc1d3b195cd8 upstream.

Put the device to avoid resource leak on path that the polling flag is
invalid.

Fixes: a831b9132065 ("NFC: Do not return EBUSY when stopping a poll that's already stopped")
Signed-off-by: Pan Bian <bianpan2016@xxxxxxx>
Link: https://lore.kernel.org/r/20210121153745.122184-1-bianpan2016@xxxxxxx
Signed-off-by: Jakub Kicinski <kuba@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>

---
net/nfc/netlink.c | 1 +
1 file changed, 1 insertion(+)

--- a/net/nfc/netlink.c
+++ b/net/nfc/netlink.c
@@ -884,6 +884,7 @@ static int nfc_genl_stop_poll(struct sk_

if (!dev->polling) {
device_unlock(&dev->dev);
+ nfc_put_device(dev);
return -EINVAL;
}