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>
{
struct power_supply_config battery_cfg = {};
struct mfi_device *mfi = NULL;
+ int err;
if (!mfi_fc_match(udev))
return -ENODEV;
&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);