]> git.hungrycats.org Git - linux/commitdiff
media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings
authorHans de Goede <hdegoede@redhat.com>
Wed, 5 Jul 2023 21:29:53 +0000 (23:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Sep 2023 07:48:31 +0000 (09:48 +0200)
[ Upstream commit 284be5693163343e1cf17c03917eecd1d6681bcf ]

When ipu_bridge_parse_rotation() and ipu_bridge_parse_orientation() run
sensor->adev is not set yet.

So if either of the dev_warn() calls about unknown values are hit this
will lead to a NULL pointer deref.

Set sensor->adev earlier, with a borrowed ref to avoid making unrolling
on errors harder, to fix this.

Fixes: 485aa3df0dff ("media: ipu3-cio2: Parse sensor orientation and rotation")
Cc: Fabian Wüthrich <me@fabwu.ch>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Daniel Scally <dan.scally@ideasonboard.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/pci/intel/ipu3/cio2-bridge.c

index 3c2accfe545510ba583ccf4a0219ac2b27586345..7fba87736b6b8106f1423fa67b96d9e78844eb9f 100644 (file)
@@ -308,6 +308,11 @@ static int cio2_bridge_connect_sensor(const struct cio2_sensor_config *cfg,
                }
 
                sensor = &bridge->sensors[bridge->n_sensors];
+               /*
+                * Borrow our adev ref to the sensor for now, on success
+                * acpi_dev_get(adev) is done further below.
+                */
+               sensor->adev = adev;
 
                ret = cio2_bridge_read_acpi_buffer(adev, "SSDB",
                                                   &sensor->ssdb,