Merge "power: supply: qti_battery_charger: Fix NULL pointer dereference"

This commit is contained in:
qctecmdr 2022-08-30 18:48:39 -07:00 committed by Gerrit - the friendly Code Review server
commit c11a99600a

View File

@ -411,8 +411,9 @@ static int write_property_id(struct battery_chg_dev *bcdev,
req_msg.hdr.type = MSG_TYPE_REQ_RESP;
req_msg.hdr.opcode = pst->opcode_set;
pr_debug("psy: %s prop_id: %u val: %u\n", pst->psy->desc->name,
req_msg.property_id, val);
if (pst->psy)
pr_debug("psy: %s prop_id: %u val: %u\n", pst->psy->desc->name,
req_msg.property_id, val);
return battery_chg_write(bcdev, &req_msg, sizeof(req_msg));
}
@ -429,8 +430,9 @@ static int read_property_id(struct battery_chg_dev *bcdev,
req_msg.hdr.type = MSG_TYPE_REQ_RESP;
req_msg.hdr.opcode = pst->opcode_get;
pr_debug("psy: %s prop_id: %u\n", pst->psy->desc->name,
req_msg.property_id);
if (pst->psy)
pr_debug("psy: %s prop_id: %u\n", pst->psy->desc->name,
req_msg.property_id);
return battery_chg_write(bcdev, &req_msg, sizeof(req_msg));
}
@ -444,8 +446,9 @@ static int get_property_id(struct psy_state *pst,
if (pst->map[i] == prop)
return i;
pr_err("No property id for property %d in psy %s\n", prop,
pst->psy->desc->name);
if (pst->psy)
pr_err("No property id for property %d in psy %s\n", prop,
pst->psy->desc->name);
return -ENOENT;
}
@ -2190,9 +2193,12 @@ static int battery_chg_probe(struct platform_device *pdev)
INIT_WORK(&bcdev->subsys_up_work, battery_chg_subsys_up_work);
INIT_WORK(&bcdev->usb_type_work, battery_chg_update_usb_type_work);
INIT_WORK(&bcdev->battery_check_work, battery_chg_check_status_work);
atomic_set(&bcdev->state, PMIC_GLINK_STATE_UP);
bcdev->dev = dev;
rc = battery_chg_register_panel_notifier(bcdev);
if (rc < 0)
return rc;
client_data.id = MSG_OWNER_BC;
client_data.name = "battery_charger";
client_data.msg_cb = battery_chg_callback;
@ -2208,6 +2214,7 @@ static int battery_chg_probe(struct platform_device *pdev)
return rc;
}
atomic_set(&bcdev->state, PMIC_GLINK_STATE_UP);
bcdev->initialized = true;
bcdev->reboot_notifier.notifier_call = battery_chg_ship_mode;
bcdev->reboot_notifier.priority = 255;
@ -2219,10 +2226,6 @@ static int battery_chg_probe(struct platform_device *pdev)
goto error;
}
rc = battery_chg_register_panel_notifier(bcdev);
if (rc < 0)
goto error;
bcdev->restrict_fcc_ua = DEFAULT_RESTRICT_FCC_UA;
platform_set_drvdata(pdev, bcdev);
bcdev->fake_soc = -EINVAL;
@ -2247,6 +2250,7 @@ static int battery_chg_probe(struct platform_device *pdev)
return 0;
error:
cancel_work_sync(&bcdev->subsys_up_work);
bcdev->initialized = false;
complete(&bcdev->ack);
pmic_glink_unregister_client(bcdev->client);
@ -2264,6 +2268,7 @@ static int battery_chg_remove(struct platform_device *pdev)
device_init_wakeup(bcdev->dev, false);
debugfs_remove_recursive(bcdev->debugfs_dir);
cancel_work_sync(&bcdev->subsys_up_work);
class_unregister(&bcdev->battery_class);
unregister_reboot_notifier(&bcdev->reboot_notifier);
rc = pmic_glink_unregister_client(bcdev->client);