From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Johan Hovold <johan@kernel.org>,
syzbot+cb035c75c03dbe34b796@syzkaller.appspotmail.com,
Jakub Kicinski <jakub.kicinski@netronome.com>,
Sasha Levin <sashal@kernel.org>,
netdev@vger.kernel.org
Subject: [PATCH AUTOSEL 4.14 16/25] NFC: pn533: fix use-after-free and memleaks
Date: Fri, 25 Oct 2019 09:57:04 -0400 [thread overview]
Message-ID: <20191025135715.25468-16-sashal@kernel.org> (raw)
In-Reply-To: <20191025135715.25468-1-sashal@kernel.org>
From: Johan Hovold <johan@kernel.org>
[ Upstream commit 6af3aa57a0984e061f61308fe181a9a12359fecc ]
The driver would fail to deregister and its class device and free
related resources on late probe errors.
Reported-by: syzbot+cb035c75c03dbe34b796@syzkaller.appspotmail.com
Fixes: 32ecc75ded72 ("NFC: pn533: change order operations in dev registation")
Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/nfc/pn533/usb.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/drivers/nfc/pn533/usb.c b/drivers/nfc/pn533/usb.c
index 5d823e965883b..fcb57d64d97e6 100644
--- a/drivers/nfc/pn533/usb.c
+++ b/drivers/nfc/pn533/usb.c
@@ -559,18 +559,25 @@ static int pn533_usb_probe(struct usb_interface *interface,
rc = pn533_finalize_setup(priv);
if (rc)
- goto error;
+ goto err_deregister;
usb_set_intfdata(interface, phy);
return 0;
+err_deregister:
+ pn533_unregister_device(phy->priv);
error:
+ usb_kill_urb(phy->in_urb);
+ usb_kill_urb(phy->out_urb);
+ usb_kill_urb(phy->ack_urb);
+
usb_free_urb(phy->in_urb);
usb_free_urb(phy->out_urb);
usb_free_urb(phy->ack_urb);
usb_put_dev(phy->udev);
kfree(in_buf);
+ kfree(phy->ack_buffer);
return rc;
}
--
2.20.1
next prev parent reply other threads:[~2019-10-25 14:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20191025135715.25468-1-sashal@kernel.org>
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 12/25] sch_netem: fix rcu splat in netem_enqueue() Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 13/25] rxrpc: Fix call ref leak Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 14/25] llc: fix sk_buff leak in llc_sap_state_process() Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 15/25] llc: fix sk_buff leak in llc_conn_service() Sasha Levin
2019-10-25 13:57 ` Sasha Levin [this message]
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 17/25] bonding: fix potential NULL deref in bond_update_slave_arr Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 18/25] net: usb: sr9800: fix uninitialized local variable Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 20/25] ath9k: dynack: fix possible deadlock in ath_dynack_node_{de}init Sasha Levin
2019-10-25 13:57 ` [PATCH AUTOSEL 4.14 24/25] ipv6: Handle race in addrconf_dad_work Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191025135715.25468-16-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=jakub.kicinski@netronome.com \
--cc=johan@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=syzbot+cb035c75c03dbe34b796@syzkaller.appspotmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).