diff mbox series

s5p-jpeg: hangle error condition in s5p_jpeg_probe

Message ID 20201113160625.1281-1-baskov@ispras.ru (mailing list archive)
State New, archived
Headers show
Series s5p-jpeg: hangle error condition in s5p_jpeg_probe | expand

Commit Message

Evgeniy Baskov Nov. 13, 2020, 4:06 p.m. UTC
If an error happens in jpeg_get_drv_data(), i.e. match fails,
jpeg->variant field is NULL, so we cannot access it.

Consider device probe failed if jpeg->variant is NULL.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Baskov Evgeiny <baskov@ispras.ru>
---
 drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Andrzej Pietrasiewicz Nov. 13, 2020, 4:59 p.m. UTC | #1
Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>

W dniu 13.11.2020 o 17:06, Baskov Evgeiny pisze:
> If an error happens in jpeg_get_drv_data(), i.e. match fails,
> jpeg->variant field is NULL, so we cannot access it.
> 
> Consider device probe failed if jpeg->variant is NULL.
> 
> Found by Linux Driver Verification project (linuxtesting.org).
> 
> Signed-off-by: Baskov Evgeiny <baskov@ispras.ru>
> ---
>   drivers/media/platform/s5p-jpeg/jpeg-core.c | 2 ++
>   1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> index 9b22dd8e34f4..026111505f5a 100644
> --- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
> +++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
> @@ -2862,6 +2862,8 @@ static int s5p_jpeg_probe(struct platform_device *pdev)
>   		return -ENOMEM;
>   
>   	jpeg->variant = jpeg_get_drv_data(&pdev->dev);
> +	if (!jpeg->variant)
> +		return -ENODEV;
>   
>   	mutex_init(&jpeg->lock);
>   	spin_lock_init(&jpeg->slock);
>
Jacek Anaszewski Nov. 13, 2020, 9:35 p.m. UTC | #2
Hi Evgeiny,

Thank you for the patch.

There is a typo in the subject: s/hangle/handle/

Otherwise:

Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>


On 11/13/20 5:06 PM, Baskov Evgeiny wrote:
> If an error happens in jpeg_get_drv_data(), i.e. match fails,
> jpeg->variant field is NULL, so we cannot access it.
> 
> Consider device probe failed if jpeg->variant is NULL.
Evgeniy Baskov Nov. 14, 2020, 7:30 a.m. UTC | #3
On 2020-11-14 00:35, Jacek Anaszewski wrote:
> There is a typo in the subject: s/hangle/handle/

Thanks for pointing out, sorry for that.

Apparently, there is also a typo in my name -> s/Evgeiny/Evgeniy/

--
Respectfully,
Baskov Evgeniy
diff mbox series

Patch

diff --git a/drivers/media/platform/s5p-jpeg/jpeg-core.c b/drivers/media/platform/s5p-jpeg/jpeg-core.c
index 9b22dd8e34f4..026111505f5a 100644
--- a/drivers/media/platform/s5p-jpeg/jpeg-core.c
+++ b/drivers/media/platform/s5p-jpeg/jpeg-core.c
@@ -2862,6 +2862,8 @@  static int s5p_jpeg_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	jpeg->variant = jpeg_get_drv_data(&pdev->dev);
+	if (!jpeg->variant)
+		return -ENODEV;
 
 	mutex_init(&jpeg->lock);
 	spin_lock_init(&jpeg->slock);