[PATCH v11 09/24] scsi: ufs: mediatek: Rework init function

sashiko-bot at kernel.org sashiko-bot at kernel.org
Tue Sep 1 09:08:25 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The return value of `ufs_mtk_mphy_power_on()` is ignored inside `ufs_mtk_init()`.
--

commit 2db99daf81ccd75c63d7195b2605aed5931e2cbe
Author: Nicolas Frattaroli <nicolas.frattaroli at collabora.com>

scsi: ufs: mediatek: Rework init function

The commit cleans up ufs_mtk_init() by removing unnecessary error messages,
removing the unused of_match_device() call, and returning early on errors
instead of zero-initializing an error variable.

> diff --git a/drivers/ufs/host/ufs-mediatek.c b/drivers/ufs/host/ufs-mediatek.c
> index f298ea6f6ecb9..c5089815696fe 100644
> --- a/drivers/ufs/host/ufs-mediatek.c
> +++ b/drivers/ufs/host/ufs-mediatek.c
[ ... ]
> @@ -1301,29 +1289,19 @@ static int ufs_mtk_get_supplies(struct ufs_mtk_host *host)
>   */
>  static int ufs_mtk_init(struct ufs_hba *hba)
>  {

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this
function's error handling, I noticed the return value of
ufs_mtk_mphy_power_on() is ignored further down:

drivers/ufs/host/ufs-mediatek.c:ufs_mtk_init() {
    ...
    err = ufs_mtk_get_supplies(host);
    if (err)
        goto out_variant_clear;

    /*
     * ufshcd_vops_init() is invoked after
     * ufshcd_setup_clock(true) in ufshcd_hba_init() thus
     * phy clock setup is skipped.
     *
     * Enable phy clocks specifically here.
     */
    ufs_mtk_mphy_power_on(hba, true);

    if (ufs_mtk_is_rtff_mtcmos(hba)) {
    ...
}

Does ignoring the return value here lead to the driver operating on unpowered
hardware if the required voltage regulators fail to enable?

ufs_mtk_mphy_power_on() calls ufs_mtk_09v_on(), which can fail if
regulator_enable() fails (returning -ENOMEM or -EIO). Proceeding as if the
phy is powered on when it is not might trigger asynchronous bus errors
on arm hardware and crash the system.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901-mt8196-ufs-v11-0-dbd007704490@collabora.com?part=9



More information about the linux-phy mailing list