Thermal - Fix possible NULL derefrence.
diff mbox

Message ID 1485752698-30248-1-git-send-email-shailendra.v@samsung.com
State Accepted
Delegated to: Eduardo Valentin
Headers show

Commit Message

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

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/thermal/imx_thermal.c |    4 ++++
 1 file changed, 4 insertions(+)

Comments

Zhang Rui Feb. 7, 2017, 3:30 a.m. UTC | #1
Just one comment,
the subject should be 
[PATCH] Thermal: imx_thermal : Fix possible NULL derefrence

On Mon, 2017-01-30 at 10:34 +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@samsung.com>

I think Eduardo will take this patch.

thanks,
rui
> ---
>  drivers/thermal/imx_thermal.c |    4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/thermal/imx_thermal.c
> b/drivers/thermal/imx_thermal.c
> index 06912f0..fb648a4 100644
> --- a/drivers/thermal/imx_thermal.c
> +++ b/drivers/thermal/imx_thermal.c
> @@ -489,6 +489,10 @@ static int imx_thermal_probe(struct
> platform_device *pdev)
>  	data->tempmon = map;
>  
>  	data->socdata = of_device_get_match_data(&pdev->dev);
> +	if (!data->socdata) {
> +		dev_err(&pdev->dev, "no device match found\n");
> +		return -ENODEV;
> +	}
>  
>  	/* make sure the IRQ flag is clear before enabling irq on
> i.MX6SX */
>  	if (data->socdata->version == TEMPMON_IMX6SX) {
--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Eduardo Valentin Feb. 19, 2017, 1:27 a.m. UTC | #2
On Tue, Feb 07, 2017 at 11:30:13AM +0800, Zhang Rui wrote:
> Just one comment,
> the subject should be 
> [PATCH] Thermal: imx_thermal : Fix possible NULL derefrence

I fixed the commit title, but I am taking this one

Patch
diff mbox

diff --git a/drivers/thermal/imx_thermal.c b/drivers/thermal/imx_thermal.c
index 06912f0..fb648a4 100644
--- a/drivers/thermal/imx_thermal.c
+++ b/drivers/thermal/imx_thermal.c
@@ -489,6 +489,10 @@  static int imx_thermal_probe(struct platform_device *pdev)
 	data->tempmon = map;
 
 	data->socdata = of_device_get_match_data(&pdev->dev);
+	if (!data->socdata) {
+		dev_err(&pdev->dev, "no device match found\n");
+		return -ENODEV;
+	}
 
 	/* make sure the IRQ flag is clear before enabling irq on i.MX6SX */
 	if (data->socdata->version == TEMPMON_IMX6SX) {