media: s5p-jpeg: handle error condition in s5p_jpeg_probe

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 Evgeniy <baskov@ispras.ru>
Acked-by: Andrzej Pietrasiewicz <andrzejtp2010@gmail.com>
Acked-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
This commit is contained in:
Baskov Evgeniy 2020-11-13 17:06:25 +01:00 committed by Mauro Carvalho Chehab
parent 3c39a16d30
commit 0862d95b43

View File

@ -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);