diff mbox

[3/3,media] exynos4-is: Fix potential NULL pointer dereference

Message ID 1375425134-17080-3-git-send-email-sachin.kamat@linaro.org (mailing list archive)
State New, archived
Headers show

Commit Message

Sachin Kamat Aug. 2, 2013, 6:32 a.m. UTC
dev->of_node could be NULL. Hence check for the same and return before
dereferencing it in the subsequent error message.

Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
---
 drivers/media/platform/exynos4-is/fimc-lite.c |    3 +++
 1 file changed, 3 insertions(+)

Comments

Hi Sachin,

On 08/02/2013 08:32 AM, Sachin Kamat wrote:
> dev->of_node could be NULL. Hence check for the same and return before
> dereferencing it in the subsequent error message.
> 
> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
> ---
>  drivers/media/platform/exynos4-is/fimc-lite.c |    3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
> index 08fbfed..214bde2 100644
> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
> @@ -1513,6 +1513,9 @@ static int fimc_lite_probe(struct platform_device *pdev)
>  		if (of_id)
>  			drv_data = (struct flite_drvdata *)of_id->data;
>  		fimc->index = of_alias_get_id(dev->of_node, "fimc-lite");
> +	} else {
> +		dev_err(dev, "device node not found\n");
> +		return -EINVAL;
>  	}

Thanks for the patch. I would prefer to add a check at very beginning
of fimc_lite_probe() like:

	if (!dev->of_node)
		return -ENODEV;

Those devices are only used on DT platforms.

--
Regards,
Sylwester
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sachin Kamat Aug. 2, 2013, 9:04 a.m. UTC | #2
Hi Sylwester,

On 2 August 2013 14:15, Sylwester Nawrocki <s.nawrocki@samsung.com> wrote:
> Hi Sachin,
>
> On 08/02/2013 08:32 AM, Sachin Kamat wrote:
>> dev->of_node could be NULL. Hence check for the same and return before
>> dereferencing it in the subsequent error message.
>>
>> Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
>> ---
>>  drivers/media/platform/exynos4-is/fimc-lite.c |    3 +++
>>  1 file changed, 3 insertions(+)
>>
>> diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
>> index 08fbfed..214bde2 100644
>> --- a/drivers/media/platform/exynos4-is/fimc-lite.c
>> +++ b/drivers/media/platform/exynos4-is/fimc-lite.c
>> @@ -1513,6 +1513,9 @@ static int fimc_lite_probe(struct platform_device *pdev)
>>               if (of_id)
>>                       drv_data = (struct flite_drvdata *)of_id->data;
>>               fimc->index = of_alias_get_id(dev->of_node, "fimc-lite");
>> +     } else {
>> +             dev_err(dev, "device node not found\n");
>> +             return -EINVAL;
>>       }
>
> Thanks for the patch. I would prefer to add a check at very beginning
> of fimc_lite_probe() like:
>
>         if (!dev->of_node)
>                 return -ENODEV;
>
> Those devices are only used on DT platforms.

OK. Sounds good. I will re-spin this one.
diff mbox

Patch

diff --git a/drivers/media/platform/exynos4-is/fimc-lite.c b/drivers/media/platform/exynos4-is/fimc-lite.c
index 08fbfed..214bde2 100644
--- a/drivers/media/platform/exynos4-is/fimc-lite.c
+++ b/drivers/media/platform/exynos4-is/fimc-lite.c
@@ -1513,6 +1513,9 @@  static int fimc_lite_probe(struct platform_device *pdev)
 		if (of_id)
 			drv_data = (struct flite_drvdata *)of_id->data;
 		fimc->index = of_alias_get_id(dev->of_node, "fimc-lite");
+	} else {
+		dev_err(dev, "device node not found\n");
+		return -EINVAL;
 	}
 
 	if (!drv_data || fimc->index >= drv_data->num_instances ||