* [PATCH] USB: apple-mfi-fastcharge: Fix use after free in probe
@ 2020-12-03 8:42 Dan Carpenter
2020-12-04 9:46 ` Bastien Nocera
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2020-12-03 8:42 UTC (permalink / raw)
To: Bastien Nocera, Lucas Tanure
Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors
This code frees "mfi" and then derefences it on the next line to get
the error code.
Fixes: b0eec52fbe63 ("USB: apple-mfi-fastcharge: Fix kfree after failed kzalloc")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
drivers/usb/misc/apple-mfi-fastcharge.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index 6dedd5498e8a..32a17b42d57b 100644
--- a/drivers/usb/misc/apple-mfi-fastcharge.c
+++ b/drivers/usb/misc/apple-mfi-fastcharge.c
@@ -178,6 +178,7 @@ static int mfi_fc_probe(struct usb_device *udev)
{
struct power_supply_config battery_cfg = {};
struct mfi_device *mfi = NULL;
+ int err;
if (!mfi_fc_match(udev))
return -ENODEV;
@@ -194,8 +195,9 @@ static int mfi_fc_probe(struct usb_device *udev)
&battery_cfg);
if (IS_ERR(mfi->battery)) {
dev_err(&udev->dev, "Can't register battery\n");
+ err = PTR_ERR(mfi->battery);
kfree(mfi);
- return PTR_ERR(mfi->battery);
+ return err;
}
mfi->udev = usb_get_dev(udev);
--
2.29.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] USB: apple-mfi-fastcharge: Fix use after free in probe
2020-12-03 8:42 [PATCH] USB: apple-mfi-fastcharge: Fix use after free in probe Dan Carpenter
@ 2020-12-04 9:46 ` Bastien Nocera
0 siblings, 0 replies; 2+ messages in thread
From: Bastien Nocera @ 2020-12-04 9:46 UTC (permalink / raw)
To: Dan Carpenter, Lucas Tanure
Cc: Greg Kroah-Hartman, linux-usb, kernel-janitors
On Thu, 2020-12-03 at 11:42 +0300, Dan Carpenter wrote:
> This code frees "mfi" and then derefences it on the next line to get
> the error code.
>
> Fixes: b0eec52fbe63 ("USB: apple-mfi-fastcharge: Fix kfree after
> failed kzalloc")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks for catching that.
Reviewed-by: Bastien Nocera <hadess@hadess.net>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-04 9:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03 8:42 [PATCH] USB: apple-mfi-fastcharge: Fix use after free in probe Dan Carpenter
2020-12-04 9:46 ` Bastien Nocera
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).