summaryrefslogtreecommitdiffstats
path: root/drivers/usb/misc
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2020-12-03 11:42:10 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-12-04 16:48:07 +0100
commitcf5fbe02042e52a5a3d93223770db39002b313c6 (patch)
tree27ec13722ffc2b2b8c905fd79a7b6b8849210793 /drivers/usb/misc
parentebad43260d225bccd57c7144a6eecbef3cd88f7f (diff)
downloadlinux-cf5fbe02042e52a5a3d93223770db39002b313c6.tar.bz2
USB: apple-mfi-fastcharge: Fix use after free in probe
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") Reviewed-by: Bastien Nocera <hadess@hadess.net> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Link: https://lore.kernel.org/r/X8ik4j8yJitVUyfU@mwanda Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/usb/misc')
-rw-r--r--drivers/usb/misc/apple-mfi-fastcharge.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/usb/misc/apple-mfi-fastcharge.c b/drivers/usb/misc/apple-mfi-fastcharge.c
index 6dedd5498e8a..ac8695195c13 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);