media: v4l2-core: fix entity initialization in device_register_subdev
authorEugen Hristev <eugen.hristev@microchip.com>
Wed, 26 Feb 2020 15:28:16 +0000 (16:28 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Thu, 5 Mar 2020 21:45:03 +0000 (22:45 +0100)
commitaead0ffbf078e0098ca6cfd1625029ff9347b10d
treea6b0b1f77cc6869fe699b891d2d95b84b062d576
parent6990570f7e0a6078e11b9c5dc13f4b6e3f49a398
media: v4l2-core: fix entity initialization in device_register_subdev

The entity variable was being initialized in the wrong place, before the
parameters have been checked.
To solve this, completely removed the entity variable and replaced it
with the initialization value : &sd->entity.
This will avoid dereferencing 'sd' pointer before it's being checked if
it's NULL.

Fixes: 61f5db549dde ("[media] v4l: Make v4l2_subdev inherit from media_entity")

Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/media/v4l2-core/v4l2-device.c