Skip to content

Commit

Permalink
ufs: fix NULL dereference when no regulators are defined
Browse files Browse the repository at this point in the history
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: Akinobu Mita <[email protected]>
Reviewed-by: Subhash Jadavani <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
mita authored and Christoph Hellwig committed Nov 26, 2014
1 parent 97cd680 commit 3e660fb
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions drivers/scsi/ufs/ufshcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
struct ufs_vreg *vreg)
{
if (!vreg)
return 0;

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

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

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

Expand Down

0 comments on commit 3e660fb

Please sign in to comment.