usb: chipidea: imx: check data->usbmisc_data against NULL before access
PATCH 1/1 usb: chipidea: imx: check data->usbmisc_data against NULL before access
From: Li Jun <[email protected]>
As usbmisc_data is optional, so add the check before access its member, this fix below static checker warning:drivers/usb/chipidea/ci_hdrc_imx.c:438 ci_hdrc_imx_probe()
warn: 'data->usbmisc_data' can also be NULL
which is introduced by Patch 15b80f7c3a7f:
"usb: chipidea: imx: enable vbus and id wakeup only for OTG events"
--- drivers/usb/chipidea/ci_hdrc_imx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
drivers/usb/chipidea/ci_hdrc_imx.c +9 -7
@@ -433,13 +433,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) goto err_clk; } -if (!IS_ERR (pdata.id_extcon.edev) || -of_property_read_bool (np,"usb-role-switch" )) - data->usbmisc_data->ext_id =1 ; - -if (!IS_ERR (pdata.vbus_extcon.edev) || -of_property_read_bool (np,"usb-role-switch" )) - data->usbmisc_data->ext_vbus =1 ; +if (data->usbmisc_data) { +if (!IS_ERR (pdata.id_extcon.edev) || +of_property_read_bool (np,"usb-role-switch" )) + data->usbmisc_data->ext_id =1 ; + +if (!IS_ERR (pdata.vbus_extcon.edev) || +of_property_read_bool (np,"usb-role-switch" )) + data->usbmisc_data->ext_vbus =1 ; + } ret =imx_usbmisc_init_post (data->usbmisc_data);if (ret) {
Signature · 1 line
2.7.4
Peter Chen
AppliedQuoted 32 lines · On 19-10-09 10:52:28, [email protected] wrote:
From: Li Jun <[email protected]>
As
usbmisc_datais optional, so add the check before access its member, this fix below static checker warning:drivers/usb/chipidea/ci_hdrc_imx.c:438ci_hdrc_imx_probe()
warn: 'data->usbmisc_data' can also be NULL
which is introduced by Patch15b80f7c3a7f:
"usb: chipidea: imx: enable vbus and id wakeup only for OTG events"Reported-by Dan Carpenter <[email protected]>Signed-off-by Li Jun <[email protected]>--- drivers/usb/chipidea/ci_hdrc_imx.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)drivers/usb/chipidea/ci_hdrc_imx.c +2
-7@@ -433,13 +433,15 @@ static int ci_hdrc_imx_probe(struct platform_device *pdev) goto err_clk; } -if (!IS_ERR (pdata.id_extcon.edev) || -of_property_read_bool (np,"usb-role-switch" )) - data->usbmisc_data->ext_id =1 ; - -if (!IS_ERR (pdata.vbus_extcon.edev) || -of_property_read_bool (np,"usb-role-switch" )) - data->usbmisc_data->ext_vbus =1 ; +if (data->usbmisc_data) { + if (!IS_ERR(pdata.id_extcon.edev) ||
drivers/usb/chipidea/ci_hdrc_imx.c static int ci_hdrc_imx_probe(struct platform_device *pdev) · line 447
Quoted 10 lines
drivers/usb/chipidea/ci_hdrc_imx.c +7
-0+ of_property_read_bool(np, "usb-role-switch")) + data->usbmisc_data->ext_id = 1; + +if (!IS_ERR (pdata.vbus_extcon.edev) || +of_property_read_bool (np,"usb-role-switch" )) + data->usbmisc_data->ext_vbus =1 ; + } ret =imx_usbmisc_init_post (data->usbmisc_data);if (ret) {
Applied, thanks.
Signature · 2 lines
Thanks, Peter Chen