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 5EAC9155327; Wed, 5 Feb 2025 15:10:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738768240; cv=none; b=EtP3bEq9vUT2c1WRZWnJjDHcmr3blEPXoawNRUMY+CH9Hm1u/tItpcyB30hOt9tfFKTeA/f0MOzRAwXcvmFcIiQrAcdS5tzJQecWNqcKW7wxs0NRAPSiaji2mDiTxBB2LqF6sAI7Q9VUhu1qgC1AeItylCjqYWQMvZWrb47b5XI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738768240; c=relaxed/simple; bh=2jwQunFIaZwzZvvAzv5wifCRiQ1zIqxbLcsUl7i3eMQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Bo0b0vRvYAPJE6ThneefBOQebJ/3CBLjV0q7C/mKPdVoGda5qSio2t5X2+V2epRokEiKhGSLxHGHESEQyT0evHEyPynzPzPs49+9UJ8spXWI1WCgB4A5urcJTt/zTYPfJ4bMVn7Gpo+n825wwLdUsFttf+o1qYkocLkJTcbwZKk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=PUm4kjfW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="PUm4kjfW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BBB05C4CEE7; Wed, 5 Feb 2025 15:10:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1738768240; bh=2jwQunFIaZwzZvvAzv5wifCRiQ1zIqxbLcsUl7i3eMQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PUm4kjfWvmgclNqipwquBYJOiHiEQHoqyqAV2fw5J02Tpamg72YhtWL/qjWIOqN1E eFPJ/5omOKBj60mf9H9JVi3iSVygUhISJ9EjhaP//esybxb06wuc6yqk0XrJKnjmjv bGL382JbLFFwC9j7meQWMhU6eRAtNTwp8I/YjW/k= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Dan Carpenter , Ming Qian , Hans Verkuil Subject: [PATCH 6.12 572/590] media: imx-jpeg: Fix potential error pointer dereference in detach_pm() Date: Wed, 5 Feb 2025 14:45:27 +0100 Message-ID: <20250205134517.150379542@linuxfoundation.org> X-Mailer: git-send-email 2.48.1 In-Reply-To: <20250205134455.220373560@linuxfoundation.org> References: <20250205134455.220373560@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dan Carpenter commit 1378ffec30367233152b7dbf4fa6a25ee98585d1 upstream. The proble is on the first line: if (jpeg->pd_dev[i] && !pm_runtime_suspended(jpeg->pd_dev[i])) If jpeg->pd_dev[i] is an error pointer, then passing it to pm_runtime_suspended() will lead to an Oops. The other conditions check for both error pointers and NULL, but it would be more clear to use the IS_ERR_OR_NULL() check for that. Fixes: fd0af4cd35da ("media: imx-jpeg: Ensure power suppliers be suspended before detach them") Cc: Signed-off-by: Dan Carpenter Reviewed-by: Ming Qian Signed-off-by: Hans Verkuil Signed-off-by: Greg Kroah-Hartman --- drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) --- a/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c +++ b/drivers/media/platform/nxp/imx-jpeg/mxc-jpeg.c @@ -2679,11 +2679,12 @@ static void mxc_jpeg_detach_pm_domains(s int i; for (i = 0; i < jpeg->num_domains; i++) { - if (jpeg->pd_dev[i] && !pm_runtime_suspended(jpeg->pd_dev[i])) + if (!IS_ERR_OR_NULL(jpeg->pd_dev[i]) && + !pm_runtime_suspended(jpeg->pd_dev[i])) pm_runtime_force_suspend(jpeg->pd_dev[i]); - if (jpeg->pd_link[i] && !IS_ERR(jpeg->pd_link[i])) + if (!IS_ERR_OR_NULL(jpeg->pd_link[i])) device_link_del(jpeg->pd_link[i]); - if (jpeg->pd_dev[i] && !IS_ERR(jpeg->pd_dev[i])) + if (!IS_ERR_OR_NULL(jpeg->pd_dev[i])) dev_pm_domain_detach(jpeg->pd_dev[i], true); jpeg->pd_dev[i] = NULL; jpeg->pd_link[i] = NULL;