From 2bc29295a6745d41770f2ec75c7ed437d344ef1e Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Tue, 2 Feb 2021 14:18:33 +0100 Subject: [PATCH] 4.4-stable patches added patches: nfc-fix-possible-resource-leak.patch nfc-fix-resource-leak-when-target-index-is-invalid.patch --- .../nfc-fix-possible-resource-leak.patch | 32 ++++++++++++++++++ ...ce-leak-when-target-index-is-invalid.patch | 33 +++++++++++++++++++ queue-4.4/series | 2 ++ 3 files changed, 67 insertions(+) create mode 100644 queue-4.4/nfc-fix-possible-resource-leak.patch create mode 100644 queue-4.4/nfc-fix-resource-leak-when-target-index-is-invalid.patch diff --git a/queue-4.4/nfc-fix-possible-resource-leak.patch b/queue-4.4/nfc-fix-possible-resource-leak.patch new file mode 100644 index 00000000000..5c2323efa50 --- /dev/null +++ b/queue-4.4/nfc-fix-possible-resource-leak.patch @@ -0,0 +1,32 @@ +From d8f923c3ab96dbbb4e3c22d1afc1dc1d3b195cd8 Mon Sep 17 00:00:00 2001 +From: Pan Bian +Date: Thu, 21 Jan 2021 07:37:45 -0800 +Subject: NFC: fix possible resource leak + +From: Pan Bian + +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 +Link: https://lore.kernel.org/r/20210121153745.122184-1-bianpan2016@163.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman + +--- + net/nfc/netlink.c | 1 + + 1 file changed, 1 insertion(+) + +--- a/net/nfc/netlink.c ++++ b/net/nfc/netlink.c +@@ -850,6 +850,7 @@ static int nfc_genl_stop_poll(struct sk_ + + if (!dev->polling) { + device_unlock(&dev->dev); ++ nfc_put_device(dev); + return -EINVAL; + } + diff --git a/queue-4.4/nfc-fix-resource-leak-when-target-index-is-invalid.patch b/queue-4.4/nfc-fix-resource-leak-when-target-index-is-invalid.patch new file mode 100644 index 00000000000..c5e0faa0112 --- /dev/null +++ b/queue-4.4/nfc-fix-resource-leak-when-target-index-is-invalid.patch @@ -0,0 +1,33 @@ +From 3a30537cee233fb7da302491b28c832247d89bbe Mon Sep 17 00:00:00 2001 +From: Pan Bian +Date: Thu, 21 Jan 2021 07:27:48 -0800 +Subject: NFC: fix resource leak when target index is invalid + +From: Pan Bian + +commit 3a30537cee233fb7da302491b28c832247d89bbe upstream. + +Goto to the label put_dev instead of the label error to fix potential +resource leak on path that the target index is invalid. + +Fixes: c4fbb6515a4d ("NFC: The core part should generate the target index") +Signed-off-by: Pan Bian +Link: https://lore.kernel.org/r/20210121152748.98409-1-bianpan2016@163.com +Signed-off-by: Jakub Kicinski +Signed-off-by: Greg Kroah-Hartman + +--- + net/nfc/rawsock.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/net/nfc/rawsock.c ++++ b/net/nfc/rawsock.c +@@ -117,7 +117,7 @@ static int rawsock_connect(struct socket + if (addr->target_idx > dev->target_next_idx - 1 || + addr->target_idx < dev->target_next_idx - dev->n_targets) { + rc = -EINVAL; +- goto error; ++ goto put_dev; + } + + rc = nfc_activate_target(dev, addr->target_idx, addr->nfc_protocol); diff --git a/queue-4.4/series b/queue-4.4/series index bc84ef11ccc..a5378ab3c5d 100644 --- a/queue-4.4/series +++ b/queue-4.4/series @@ -24,3 +24,5 @@ mac80211-pause-tx-while-changing-interface-type.patch can-dev-prevent-potential-information-leak-in-can_fi.patch iommu-vt-d-gracefully-handle-dmar-units-with-no-supported-address-widths.patch iommu-vt-d-don-t-dereference-iommu_device-if-iommu_api-is-not-built.patch +nfc-fix-resource-leak-when-target-index-is-invalid.patch +nfc-fix-possible-resource-leak.patch -- 2.39.5