Skip to content

Commit 3e660fb

Browse files
mitaChristoph Hellwig
authored andcommitted
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: Akinobu Mita <[email protected]> Reviewed-by: Subhash Jadavani <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 97cd680 commit 3e660fb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/scsi/ufs/ufshcd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,12 +4268,18 @@ static int ufshcd_config_vreg_load(struct device *dev, struct ufs_vreg *vreg,
42684268
static inline int ufshcd_config_vreg_lpm(struct ufs_hba *hba,
42694269
struct ufs_vreg *vreg)
42704270
{
4271+
if (!vreg)
4272+
return 0;
4273+
42714274
return ufshcd_config_vreg_load(hba->dev, vreg, UFS_VREG_LPM_LOAD_UA);
42724275
}
42734276

42744277
static inline int ufshcd_config_vreg_hpm(struct ufs_hba *hba,
42754278
struct ufs_vreg *vreg)
42764279
{
4280+
if (!vreg)
4281+
return 0;
4282+
42774283
return ufshcd_config_vreg_load(hba->dev, vreg, vreg->max_uA);
42784284
}
42794285

0 commit comments

Comments
 (0)