summaryrefslogtreecommitdiff
path: root/drivers/usb
diff options
context:
space:
mode:
authorLi Jun <jun.li@freescale.com>2015-08-11 15:52:10 +0800
committerNitin Garg <nitin.garg@nxp.com>2016-01-14 10:59:28 -0600
commita8e89facf49ba2f6aa2b225fdb3ef349c574de90 (patch)
treeb16c286e2e3f6d8d4a9cdd9be3c607ea2814dc5a /drivers/usb
parentcb115e10a39d5c4ab0e138bc35eabde95dc48657 (diff)
MLK-11340-43 usb: chipidea: imx: fix usb charger detection init NULL pointer
Dereference the charger->psy after the power_supply is created to fix the null pointer issue. Signed-off-by: Li Jun <b47624@freescale.com>
Diffstat (limited to 'drivers/usb')
-rw-r--r--drivers/usb/chipidea/ci_hdrc_imx.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/drivers/usb/chipidea/ci_hdrc_imx.c b/drivers/usb/chipidea/ci_hdrc_imx.c
index e969156382d4..e1e4040128c2 100644
--- a/drivers/usb/chipidea/ci_hdrc_imx.c
+++ b/drivers/usb/chipidea/ci_hdrc_imx.c
@@ -396,7 +396,6 @@ static int imx_usb_charger_get_property(struct power_supply *psy,
static int imx_usb_register_charger(struct usb_charger *charger,
const char *name)
{
- struct power_supply *psy = charger->psy;
struct power_supply_desc *desc = &charger->psy_desc;
if (!charger->dev)
@@ -414,15 +413,16 @@ static int imx_usb_register_charger(struct usb_charger *charger,
desc->properties = imx_usb_charger_power_props;
desc->num_properties = ARRAY_SIZE(imx_usb_charger_power_props);
desc->get_property = imx_usb_charger_get_property;
- psy->supplied_to = imx_usb_charger_supplied_to;
- psy->num_supplicants = sizeof(imx_usb_charger_supplied_to)
- / sizeof(char *);
- charger->psy = devm_power_supply_register(charger->dev->parent,
+ charger->psy = devm_power_supply_register(charger->dev,
&charger->psy_desc, NULL);
if (IS_ERR(charger->psy))
return PTR_ERR(charger->psy);
+ charger->psy->supplied_to = imx_usb_charger_supplied_to;
+ charger->psy->num_supplicants = sizeof(imx_usb_charger_supplied_to)
+ / sizeof(char *);
+
return 0;
}