From patchwork Wed Sep 11 11:52:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 827491 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 B9EC3185B7B; Wed, 11 Sep 2024 11:53:30 +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=1726055610; cv=none; b=P+c7LBoUG4EsZZT477zbgiChntf2wM1pHegPVoNrCqV6EO38k+pnRUiY5oDqW67pZmoqd/FsE+dqeSblKLcf/h5dPismUbB6O1PmqZCDQiBeYtxkkbO64skM6q7FiSFKTXotKmYPQW58VVRooiARSBGa4B+yJCZQd+qFNPq69p4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726055610; c=relaxed/simple; bh=zhjs0HCCkCG44moeklx+BEEW7yaiU/+Dj4UI+iaJ2eI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=elkiURA8xsaE/iOujsAbzJv/z/wzcV0JDvLIGmPIhuQBRmWRs1TGy9MBhiJ0TctBKXgTLdJNLG0wnyWNruvDrFAST6EGQpaeeqYgsC/ZfuH1KydyJ8OXFiOWVCIQ9HFOr1/LKB+ls1OjludhGr+tZ10bZJQuw+P2BtOpjC9QyLA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VQqh694f; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VQqh694f" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 661A4C4CEC5; Wed, 11 Sep 2024 11:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726055610; bh=zhjs0HCCkCG44moeklx+BEEW7yaiU/+Dj4UI+iaJ2eI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VQqh694fEMkFMNJ5j/gBTLOa6DLKSlMgjzgp09f/Z6k6vObr9ha03j7vAZvQppN26 54E3beImSDwAVbyKgYY5Moy1RiVl70z6B99BS8EYcyOrosoEJLFRwaNR87NCBvQ4eg O9tJAD4ea+oJ7rzsWxJ8ElTZEtZyTtmNrruPih3OJXwEF0qlyoFKDfsiTM49QH9cFR MjkFT7OL4dtbHwKIr2Oa0Vl61RxZo14+6x8M/Bkawye8l3NzufbzBAsf0ho1tMUm4q khzx5+DlUxJZn/kiSgHrvt0zPKH6JCp3688qVUOY/EqhxZVmlWEMVNEHq83BANkpf+ Dy+45qFLRFxPA== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1soLuv-000000002rM-1Vkj; Wed, 11 Sep 2024 13:53:49 +0200 From: Johan Hovold To: Vinod Koul , Kishon Vijay Abraham I Cc: Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 1/4] phy: qcom: qmp-usb: fix NULL-deref on runtime suspend Date: Wed, 11 Sep 2024 13:52:50 +0200 Message-ID: <20240911115253.10920-2-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240911115253.10920-1-johan+linaro@kernel.org> References: <20240911115253.10920-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") removed most users of the platform device driver data, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks. Restore the driver data initialisation at probe to avoid a NULL-pointer dereference on runtime suspend. Apparently no one uses runtime PM, which currently needs to be enabled manually through sysfs, with this driver. Fixes: 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") Cc: stable@vger.kernel.org # 6.2 Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-usb.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c index 49f4a53f9b2c..76068393e4ba 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb.c @@ -2191,6 +2191,7 @@ static int qmp_usb_probe(struct platform_device *pdev) return -ENOMEM; qmp->dev = dev; + dev_set_drvdata(dev, qmp); qmp->cfg = of_device_get_match_data(dev); if (!qmp->cfg) From patchwork Wed Sep 11 11:52:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 827492 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 B9E72185B48; Wed, 11 Sep 2024 11:53:30 +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=1726055610; cv=none; b=pfgjh7XmRyA8V9prg3j94ZuKJDNu8vOj9tdnvcLXZE3hFuPDcO3UzZVxDTBeq3BrDFOXLHsPZBwk3HK/lc9kS4YRlfSUnBrTfgGqHMbbPjMq+V1ULZxu1vsQym/RDIheR1QooEGb/UAZN2w9GN5oW/YufD9L23smTDeE22sFQfk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726055610; c=relaxed/simple; bh=pY7ZEUhLGzksrKZfDgxIIs9lG9DM9Yt0khFnqvZZ+d4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nNMkL23mcV0eebMMuBG28eMvqChN8A+2gmIO7n74tBhatxoZR43LXLsucW/UWvJ0sGcBhJ4DGOd8/PZg7lFAYBgp6zL15wlufXhpeDVgJDuGIFdIhUH9a4wgOeG+0z85nsid2x0uUa15LvB9pxTIlh9Pwrlc9+aXGpNRJVlG0sQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vM51sJdD; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vM51sJdD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CFADC4CECE; Wed, 11 Sep 2024 11:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726055610; bh=pY7ZEUhLGzksrKZfDgxIIs9lG9DM9Yt0khFnqvZZ+d4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vM51sJdDqQ4+sKY3Ntz1M0MKkDsCRj3bG5+TWbNJNMvBNAjn4CE/o3GDYl8iFKpii MnYaKOSy9gUC/6kebjavN8KiclPXzIJOZFFzGtALkj4NoWRODotpj405ad8gQzPz64 yf670FHTUIQUIAGy82aTVbRYCA4wzOyd2QdAYLqVNq/OSRkYDxRiXd344KWWU/XNKX 4WSRLtWZ5nYLlmy122coEfpEZ8Wl2kW4rGAjOKSYjbVMFenGBM4YyojeIbzNzLAgHo bwiaV4EZ/TbzUyHp57BPm2kkQ+d9ETmhg0WZCpTAA7MVIOZr4xSlWqem5bTrJsg8AG yXbZzk4pcViJw== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1soLuv-000000002rO-1ufT; Wed, 11 Sep 2024 13:53:49 +0200 From: Johan Hovold To: Vinod Koul , Kishon Vijay Abraham I Cc: Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org Subject: [PATCH 2/4] phy: qcom: qmp-usb-legacy: fix NULL-deref on runtime suspend Date: Wed, 11 Sep 2024 13:52:51 +0200 Message-ID: <20240911115253.10920-3-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240911115253.10920-1-johan+linaro@kernel.org> References: <20240911115253.10920-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 413db06c05e7 ("phy: qcom-qmp-usb: clean up probe initialisation") removed most users of the platform device driver data from the qcom-qmp-usb driver, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks. This bug was later reproduced when the driver was copied to create the qmp-usb-legacy driver. Restore the driver data initialisation at probe to avoid a NULL-pointer dereference on runtime suspend. Apparently no one uses runtime PM, which currently needs to be enabled manually through sysfs, with these drivers. Fixes: e464a3180a43 ("phy: qcom-qmp-usb: split off the legacy USB+dp_com support") Cc: stable@vger.kernel.org # 6.6 Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c b/drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c index 6d0ba39c1943..8bf951b0490c 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-usb-legacy.c @@ -1248,6 +1248,7 @@ static int qmp_usb_legacy_probe(struct platform_device *pdev) return -ENOMEM; qmp->dev = dev; + dev_set_drvdata(dev, qmp); qmp->cfg = of_device_get_match_data(dev); if (!qmp->cfg) From patchwork Wed Sep 11 11:52:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 827493 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 B9F161865E2; Wed, 11 Sep 2024 11:53:30 +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=1726055610; cv=none; b=jKK0R1jZb5Hbk+YXnzrYTT0lbYuouKLVQeCONQsfTHeCRx9803/WGwCfGQKdGYomtmG9Ij7C9B1ArxbAoIMgB7sqdD/gZDq1wCwxZE0Wiev/cuHN081WWs1iXDvTotMAcIw8kO6T52wVtgNRt9/Kbz1zUq9Nh6FOmn5elDQT5Zk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726055610; c=relaxed/simple; bh=IZP0j0URHKg34Z+uDXsss8wvd9andjBbgzMWCUodLmI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=P84tqGEyia/f1MwR5y1NOkoCdN2/du75x1Do+KWAVYa8uiM6+kKNX0eGXNy0N5aHaESjU7SVdeSn+FzJY/393obfzql1R9K6jp9b6Qj5rVHYfafiszifGi4BqKstbEWidUD1yQsahczW3VHFTVCPuGn+1dyXQ+E6IqqS60jjrew= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=d/fdVFS6; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="d/fdVFS6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 66CDBC4CEC6; Wed, 11 Sep 2024 11:53:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1726055610; bh=IZP0j0URHKg34Z+uDXsss8wvd9andjBbgzMWCUodLmI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d/fdVFS6XEQFeADxLTiFke6jAgpiRerRJ5wROxrE+lBd1o2RdSV9MdHWHj+uZSyTk Aa5yFtJdtYvhZ4UHC/ds5w2sYPQ0PCVu9jxL/RF53gk2LT+9lPc9u1lgvqFH1Gsrn3 c3payVXt+6GIJOX1elOndTTHvUAJIy+zVsKuaWTD2xC7SOBeLISnYqnwBe2lLhFGNF 0+Uhf8XscvoLCz/oFnKyiQrLcR8fUIm+ySWeCnI56xoHqp156zYYl8Qnj4Wj3SSaWb wfejaQED14F7pR9NtI+WP9HlZuMqUSWrvavnVe9boWENRN6WyK9eTdpgmG2WSqV+E6 WT0MlbEwtZn8g== Received: from johan by xi.lan with local (Exim 4.97.1) (envelope-from ) id 1soLuv-000000002rS-2cQ7; Wed, 11 Sep 2024 13:53:49 +0200 From: Johan Hovold To: Vinod Koul , Kishon Vijay Abraham I Cc: Dmitry Baryshkov , linux-arm-msm@vger.kernel.org, linux-phy@lists.infradead.org, linux-kernel@vger.kernel.org, Johan Hovold Subject: [PATCH 4/4] phy: qcom: qmp-usb: move driver data initialisation earlier Date: Wed, 11 Sep 2024 13:52:53 +0200 Message-ID: <20240911115253.10920-5-johan+linaro@kernel.org> X-Mailer: git-send-email 2.44.2 In-Reply-To: <20240911115253.10920-1-johan+linaro@kernel.org> References: <20240911115253.10920-1-johan+linaro@kernel.org> Precedence: bulk X-Mailing-List: linux-arm-msm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Commit 44aff8e31080 ("phy: qcom-qmp-combo: clean up probe initialisation") removed most users of the platform device driver data, but mistakenly also removed the initialisation despite the data still being used in the runtime PM callbacks. The initialisation was soon after restored by commit 83a0bbe39b17 ("phy: qcom-qmp-combo: add support for updated sc8280xp binding") but now happens slightly later during probe. This should not cause any trouble currently as runtime PM needs to be enabled manually through sysfs and the platform device would not be suspended before the PHY has been registered anyway. Move the driver data initialisation to avoid a NULL-pointer dereference on runtime suspend if runtime PM is ever enabled by default in this driver. Fixes: 44aff8e31080 ("phy: qcom-qmp-combo: clean up probe initialisation") Signed-off-by: Johan Hovold --- drivers/phy/qualcomm/phy-qcom-qmp-combo.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c index c478bf74817a..ddecf34968fd 100644 --- a/drivers/phy/qualcomm/phy-qcom-qmp-combo.c +++ b/drivers/phy/qualcomm/phy-qcom-qmp-combo.c @@ -3649,6 +3649,7 @@ static int qmp_combo_probe(struct platform_device *pdev) return -ENOMEM; qmp->dev = dev; + dev_set_drvdata(dev, qmp); qmp->orientation = TYPEC_ORIENTATION_NORMAL; @@ -3725,8 +3726,6 @@ static int qmp_combo_probe(struct platform_device *pdev) phy_set_drvdata(qmp->dp_phy, qmp); - dev_set_drvdata(dev, qmp); - if (usb_np == dev->of_node) phy_provider = devm_of_phy_provider_register(dev, qmp_combo_phy_xlate); else