diff mbox

Mmc: host - Fix possible NULL derefrence.

Message ID 1485751698-29036-1-git-send-email-shailendra.v@samsung.com
State New
Headers show

Commit Message

shailendra.v@samsung.com Jan. 30, 2017, 4:48 a.m. UTC
of_match_device could return NULL, and so can cause a NULL
pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/mmc/host/mxs-mmc.c |    5 +++++
 1 file changed, 5 insertions(+)

Comments

Marek Vasut Jan. 30, 2017, 12:12 p.m. UTC | #1
On 01/30/2017 05:48 AM, Shailendra Verma wrote:
> of_match_device could return NULL, and so can cause a NULL
> pointer dereference later.
> 
> Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
> ---
>  drivers/mmc/host/mxs-mmc.c |    5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index 44ecebd..d12a5b7 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -581,6 +581,11 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>  	struct regulator *reg_vmmc;
>  	struct mxs_ssp *ssp;
>  
> +	if (!of_id) {
> +		dev_err(&pdev->dev, "Error: No device match found\n");
> +		return -ENODEV;
> +	}

The probe won't be called if OF match doesn't happen in the first place,
so this check is redundant, no ?

>  	irq_err = platform_get_irq(pdev, 0);
>  	if (irq_err < 0)
>  		return irq_err;
>
diff mbox

Patch

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 44ecebd..d12a5b7 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -581,6 +581,11 @@  static int mxs_mmc_probe(struct platform_device *pdev)
 	struct regulator *reg_vmmc;
 	struct mxs_ssp *ssp;
 
+	if (!of_id) {
+		dev_err(&pdev->dev, "Error: No device match found\n");
+		return -ENODEV;
+	}
+
 	irq_err = platform_get_irq(pdev, 0);
 	if (irq_err < 0)
 		return irq_err;