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 1ABF1221734; Mon, 23 Jun 2025 21:30:26 +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=1750714226; cv=none; b=X4WV1d5cSPmQTU5cm0L9hLNRtsEi73Tex/CFUuOPxI+3KXV0bfqUpkGtAyhKQuBeqmjYR7/VMO+e3FcStka695KxcVgzhxiTDoLM+FQmowCwS/zCw/Eck+xLrUw4cSuUllMaV2RZXOWgrMaSXdXR1eU1w0uL4CBRLbLsvndJj+Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750714226; c=relaxed/simple; bh=QH9IxPSWLqMQkdoI4kuDmg0NP0hb5lFQgEy1Tub6GlM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=auIWKe4U/7OibC3knx7PkwBe8p1DhDOD8lc9VZzsGwv1qzjSKIbLfxw+8x9BE0akIacGb2skfpV0bgM0D2saNn5XcsbCtNEh9lWp5UJlXu050X4x3+ZPLK71hiw0RvspO5VtB49YLK07v8zxZHj6G1vcXmaSbIc6XwIlpo/iGsk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=qmh/xxbq; 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="qmh/xxbq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94BF4C4CEEA; Mon, 23 Jun 2025 21:30:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1750714225; bh=QH9IxPSWLqMQkdoI4kuDmg0NP0hb5lFQgEy1Tub6GlM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qmh/xxbqCimPDldWYEVPDLjqhFnEXxWrdnymkHnFRWmaqSsamaO041aRjnVD7MXCB cOEinzLKs+JKndt/6QEK82UnvrTkPJt6AMJZcms/2BJ7ZCD2D7B9pDo64peMEpCLMR KGGYZzvL4buj8cp1VokqRYjTARQ+fseFzANIEsyI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Chenyuan Yang , Johan Hovold , Krzysztof Kozlowski , Johan Hovold , Dmitry Baryshkov , Vinod Koul , Sasha Levin Subject: [PATCH 6.1 153/508] phy: qcom-qmp-usb: Fix an NULL vs IS_ERR() bug Date: Mon, 23 Jun 2025 15:03:18 +0200 Message-ID: <20250623130649.045730615@linuxfoundation.org> X-Mailer: git-send-email 2.50.0 In-Reply-To: <20250623130645.255320792@linuxfoundation.org> References: <20250623130645.255320792@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.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Chenyuan Yang [ Upstream commit d14402a38c2d868cacb1facaf9be908ca6558e59 ] The qmp_usb_iomap() helper function currently returns the raw result of devm_ioremap() for non-exclusive mappings. Since devm_ioremap() may return a NULL pointer and the caller only checks error pointers with IS_ERR(), NULL could bypass the check and lead to an invalid dereference. Fix the issue by checking if devm_ioremap() returns NULL. When it does, qmp_usb_iomap() now returns an error pointer via IOMEM_ERR_PTR(-ENOMEM), ensuring safe and consistent error handling. Signed-off-by: Chenyuan Yang Fixes: a5d6b1ac56cb ("phy: qcom-qmp-usb: fix memleak on probe deferral") CC: Johan Hovold CC: Krzysztof Kozlowski Reviewed-by: Johan Hovold Reviewed-by: Dmitry Baryshkov Link: https://lore.kernel.org/r/20250414125050.2118619-1-chenyuan0y@gmail.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 605591314f256..a85bb0e1cd8c8 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2428,12 +2428,16 @@ static void __iomem *qmp_usb_iomap(struct device *dev, struct device_node *np, int index, bool exclusive) { struct resource res; + void __iomem *mem; if (!exclusive) { if (of_address_to_resource(np, index, &res)) return IOMEM_ERR_PTR(-EINVAL); - return devm_ioremap(dev, res.start, resource_size(&res)); + mem = devm_ioremap(dev, res.start, resource_size(&res)); + if (!mem) + return IOMEM_ERR_PTR(-ENOMEM); + return mem; } return devm_of_iomap(dev, np, index, NULL); -- 2.39.5