USB: apple-mfi-fastcharge: Fix kfree after failed kzalloc
kfree don't need to be called after a failed kzalloc Signed-off-by: Lucas Tanure <tanure@linux.com> Link: https://lore.kernel.org/r/20201115102837.331335-1-tanure@linux.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
5a569343e8
commit
b0eec52fbe
1 changed files with 4 additions and 11 deletions
|
@ -178,16 +178,13 @@ static int mfi_fc_probe(struct usb_device *udev)
|
||||||
{
|
{
|
||||||
struct power_supply_config battery_cfg = {};
|
struct power_supply_config battery_cfg = {};
|
||||||
struct mfi_device *mfi = NULL;
|
struct mfi_device *mfi = NULL;
|
||||||
int err;
|
|
||||||
|
|
||||||
if (!mfi_fc_match(udev))
|
if (!mfi_fc_match(udev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL);
|
mfi = kzalloc(sizeof(struct mfi_device), GFP_KERNEL);
|
||||||
if (!mfi) {
|
if (!mfi)
|
||||||
err = -ENOMEM;
|
return -ENOMEM;
|
||||||
goto error;
|
|
||||||
}
|
|
||||||
|
|
||||||
battery_cfg.drv_data = mfi;
|
battery_cfg.drv_data = mfi;
|
||||||
|
|
||||||
|
@ -197,18 +194,14 @@ static int mfi_fc_probe(struct usb_device *udev)
|
||||||
&battery_cfg);
|
&battery_cfg);
|
||||||
if (IS_ERR(mfi->battery)) {
|
if (IS_ERR(mfi->battery)) {
|
||||||
dev_err(&udev->dev, "Can't register battery\n");
|
dev_err(&udev->dev, "Can't register battery\n");
|
||||||
err = PTR_ERR(mfi->battery);
|
kfree(mfi);
|
||||||
goto error;
|
return PTR_ERR(mfi->battery);
|
||||||
}
|
}
|
||||||
|
|
||||||
mfi->udev = usb_get_dev(udev);
|
mfi->udev = usb_get_dev(udev);
|
||||||
dev_set_drvdata(&udev->dev, mfi);
|
dev_set_drvdata(&udev->dev, mfi);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
|
||||||
kfree(mfi);
|
|
||||||
return err;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mfi_fc_disconnect(struct usb_device *udev)
|
static void mfi_fc_disconnect(struct usb_device *udev)
|
||||||
|
|
Loading…
Add table
Reference in a new issue