RE: [PATCH v2] usb: phy: mxs: Fix NULL pointer dereference on i.MX23/28

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Fabio Estevam [mailto:festevam@xxxxxxxxx]
> Sent: Thursday, January 18, 2018 10:23 AM
> To: balbi@xxxxxxxxxx
> Cc: Jun Li <jun.li@xxxxxxx>; baolin.wang@xxxxxxxxxx; Peter Chen
> <peter.chen@xxxxxxx>; linux-usb@xxxxxxxxxxxxxxx; Fabio Estevam
> <fabio.estevam@xxxxxxx>
> Subject: [PATCH v2] usb: phy: mxs: Fix NULL pointer dereference on i.MX23/28
> 
> From: Fabio Estevam <fabio.estevam@xxxxxxx>
> 
> Commit e93650994a95 ("usb: phy: mxs: add usb charger type detection") causes
> the following kernel hang on i.MX28:
> 
> [    2.207973] usbcore: registered new interface driver usb-storage
> [    2.235659] Unable to handle kernel NULL pointer dereference at virtual
> address 00000188
> [    2.244195] pgd = (ptrval)
> [    2.246994] [00000188] *pgd=00000000
> [    2.250676] Internal error: Oops: 5 [#1] ARM
> [    2.254979] Modules linked in:
> [    2.258089] CPU: 0 PID: 1 Comm: swapper Not tainted 4.15.0-rc8-next-
> 20180117-00002-g75d5f21 #7
> [    2.266724] Hardware name: Freescale MXS (Device Tree)
> [    2.271921] PC is at regmap_read+0x0/0x5c
> [    2.275977] LR is at mxs_phy_charger_detect+0x34/0x1dc
> 
> mxs_phy_charger_detect() makes accesses to the anatop registers via regmap,
> however i.MX23/28 do not have such registers, which causes a NULL pointer
> dereference.
> 
> Fix the issue by doing a NULL check on the 'regmap' pointer.
> 
> Fixes: e93650994a95 ("usb: phy: mxs: add usb charger type detection")
> Signed-off-by: Fabio Estevam <fabio.estevam@xxxxxxx>

Reviewed-by: Li Jun <jun.li@xxxxxxx>

> ---
> Changes since v1:
> - Perform a NULL check on regmap (Jun Li)
> 
>  drivers/usb/phy/phy-mxs-usb.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index da031c4..4e2eb9d 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -602,6 +602,9 @@ static enum usb_charger_type
> mxs_phy_charger_detect(struct usb_phy *phy)
>  	void __iomem *base = phy->io_priv;
>  	enum usb_charger_type chgr_type = UNKNOWN_TYPE;
> 
> +	if (!regmap)
> +		return UNKNOWN_TYPE;
> +
>  	if (mxs_charger_data_contact_detect(mxs_phy))
>  		return chgr_type;
> 
> --
> 2.7.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux