summaryrefslogtreecommitdiff
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2023-07-06 00:29:53 +0300
committerMauro Carvalho Chehab <mchehab@kernel.org>2023-08-10 08:58:40 +0300
commit284be5693163343e1cf17c03917eecd1d6681bcf (patch)
tree552e0aefd08fa0ae5cdb1157445ce8529fe3fd93 /drivers/media/pci
parentceee7fb05bad66d3ae295664beb348673681e498 (diff)
downloadlinux-284be5693163343e1cf17c03917eecd1d6681bcf.tar.xz
media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings
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>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/intel/ipu-bridge.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/media/pci/intel/ipu-bridge.c b/drivers/media/pci/intel/ipu-bridge.c
index bd67c3e990ea..c23c1ee30ad9 100644
--- a/drivers/media/pci/intel/ipu-bridge.c
+++ b/drivers/media/pci/intel/ipu-bridge.c
@@ -308,6 +308,11 @@ static int ipu_bridge_connect_sensor(const struct ipu_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 = ipu_bridge_read_acpi_buffer(adev, "SSDB",
&sensor->ssdb,