Re: [PATCH] Usb: host - Fix possible NULL derefrence.

From: Greg Kroah-Hartman
Date: Mon Jan 30 2017 - 01:56:17 EST


On Mon, Jan 30, 2017 at 10:36:29AM +0530, Shailendra Verma wrote:
> of_device_get_match_data could return NULL, and so can cause
> a NULL pointer dereference later.
>
> Signed-off-by: Shailendra Verma <shailendra.v@xxxxxxxxxxx>
> ---
> drivers/usb/host/xhci-tegra.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/usb/host/xhci-tegra.c b/drivers/usb/host/xhci-tegra.c
> index a59fafb..890c778 100644
> --- a/drivers/usb/host/xhci-tegra.c
> +++ b/drivers/usb/host/xhci-tegra.c
> @@ -903,6 +903,10 @@ static int tegra_xusb_probe(struct platform_device *pdev)
> return -ENOMEM;
>
> tegra->soc = of_device_get_match_data(&pdev->dev);
> + if (!tegra->soc) {

How would the driver be loaded and the probe function called if this
returns NULL?

Is this ever possible?

thanks,

greg k-h