diff mbox series

scsi: ufs: Fix to avoid a potential NULL pointer dereference

Message ID 20190319003038.12896-1-pakki001@umn.edu (mailing list archive)
State Changes Requested
Headers show
Series scsi: ufs: Fix to avoid a potential NULL pointer dereference | expand

Commit Message

Aditya Pakki March 19, 2019, 12:30 a.m. UTC
In tc_dwc_g210_pltfm_probe, of_match_node can return a NULL pointer
in case of failure. The patch avoids a potential NULL pointer dereference
in such scenarios.

Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
 drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Alim Akhtar March 19, 2019, 1:45 a.m. UTC | #1
On Tue, Mar 19, 2019 at 6:01 AM Aditya Pakki <pakki001@umn.edu> wrote:
>
> In tc_dwc_g210_pltfm_probe, of_match_node can return a NULL pointer
> in case of failure. The patch avoids a potential NULL pointer dereference
> in such scenarios.
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
>  drivers/scsi/ufs/tc-dwc-g210-pltfrm.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
> index 6dfe5a9206e9..2b5bc6bd715e 100644
> --- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
> +++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
> @@ -61,6 +61,8 @@ static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
>         struct device *dev = &pdev->dev;
>
>         of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
> +       if (!of_id)
> +               return -ENXIO;
May be just return -ENODEV
>         vops = (struct ufs_hba_variant_ops *)of_id->data;
>
>         /* Perform generic probe */
> --
> 2.17.1
>
diff mbox series

Patch

diff --git a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
index 6dfe5a9206e9..2b5bc6bd715e 100644
--- a/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
+++ b/drivers/scsi/ufs/tc-dwc-g210-pltfrm.c
@@ -61,6 +61,8 @@  static int tc_dwc_g210_pltfm_probe(struct platform_device *pdev)
 	struct device *dev = &pdev->dev;
 
 	of_id = of_match_node(tc_dwc_g210_pltfm_match, dev->of_node);
+	if (!of_id)
+		return -ENXIO;
 	vops = (struct ufs_hba_variant_ops *)of_id->data;
 
 	/* Perform generic probe */