From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F24BA1170E for ; Mon, 11 Sep 2023 14:17:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 78D3BC433C8; Mon, 11 Sep 2023 14:17:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1694441842; bh=cFx53V1nR3le4Skggb/jXxBehg0tZgOPMG3qkkdxJ3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AeaDa9Kk+b7c4ouk6ZR+AKODEVLEkwIG14w+Lc7I6t06vpEcokGOb28gKQMnCur/K S7qFsSOVIUpPBfqOsHHTCL+j9h8aZzoUieizS5cMJckmk8T7pr5qlKOI1wyUg6tMg3 wE+6shDFfuHU0oXxSkBYq/SO/7gudmrpi8JQtcM8= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?Fabian=20W=C3=BCthrich?= , Hans de Goede , Daniel Scally , Sakari Ailus , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 6.5 529/739] media: ipu-bridge: Fix null pointer deref on SSDB/PLD parsing warnings Date: Mon, 11 Sep 2023 15:45:28 +0200 Message-ID: <20230911134705.884092553@linuxfoundation.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20230911134650.921299741@linuxfoundation.org> References: <20230911134650.921299741@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.5-stable review patch. If anyone has any objections, please let me know. ------------------ From: Hans de Goede [ 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 Signed-off-by: Hans de Goede Reviewed-by: Daniel Scally Signed-off-by: Sakari Ailus Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/pci/intel/ipu3/cio2-bridge.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/media/pci/intel/ipu3/cio2-bridge.c b/drivers/media/pci/intel/ipu3/cio2-bridge.c index 3c2accfe54551..7fba87736b6b8 100644 --- a/drivers/media/pci/intel/ipu3/cio2-bridge.c +++ b/drivers/media/pci/intel/ipu3/cio2-bridge.c @@ -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, -- 2.40.1