media: ov2680: don't register the v4l2 subdevice before checking chip ID
authorJavier Martinez Canillas <javierm@redhat.com>
Sat, 1 Sep 2018 12:46:29 +0000 (08:46 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 20 Nov 2019 17:46:52 +0000 (18:46 +0100)
commit525552a0e849347bb7779622b2d1807314d65ea8
tree7f10d0eee1c2bf6ff32931159ecc860f172f5943
parentf4683c89808fa1bbb2dbac995fc5d7bf873f3db9
media: ov2680: don't register the v4l2 subdevice before checking chip ID

[ Upstream commit b7a417628abf49dae98cb80a272dc133b0e4d1a3 ]

The driver registers the v4l2 subdevice before attempting to power on the
chip and checking its ID. This means that a media device driver that it's
waiting for this subdevice to be bound, will prematurely expose its media
device node to userspace because if something goes wrong the media entity
will be cleaned up again on the ov2680 probe function.

This also simplifies the probe function error path since no initialization
is made before attempting to enable the resources or checking the chip ID.

Fixes: 3ee47cad3e69 ("media: ov2680: Add Omnivision OV2680 sensor driver")

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/i2c/ov2680.c