Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3e660fbe authored by Akinobu Mita's avatar Akinobu Mita Committed by Christoph Hellwig
Browse files

ufs: fix NULL dereference when no regulators are defined



If no voltage supply regulators are defined for the UFS devices (assumed
they are always-on), ufshcd_config_vreg_load() can be called on
suspend/resume paths with vreg == NULL as hba->vreg_info.vcc* equal to
NULL, and it causes NULL pointer dereference.

This fixes it by making ufshcd_config_vreg_{h,l}pm noop when no regulators
are defined.

Signed-off-by: default avatarAkinobu Mita <mita@fixstars.com>
Reviewed-by: default avatarSubhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
parent 97cd6805
Loading
Loading
Loading
Loading
+6 −0
Original line number Original line Diff line number Diff line
@@ -4268,12 +4268,18 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
					 struct ufs_vreg *vreg)
					 struct ufs_vreg *vreg)
{
{
	if (!vreg)
		return 0;

	return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
	return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
}
}


static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
					 struct ufs_vreg *vreg)
					 struct ufs_vreg *vreg)
{
{
	if (!vreg)
		return 0;

	return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
	return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
}
}