Reviewed-by: Subhash Jadavani <subha...@codeaurora.org> -----Original Message----- From: Akinobu Mita [mailto:akinobu.m...@gmail.com] Sent: Tuesday, November 18, 2014 6:03 AM To: linux-scsi@vger.kernel.org Cc: Akinobu Mita; Akinobu Mita; Vinayak Holikatti; Subhash Jadavani; Dolev Raviv; Sujit Reddy Thumma; Yaniv Gardi; Christoph Hellwig; James E.J. Bottomley Subject: [PATCH 2/2] scsi: 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 <m...@fixstars.com> Cc: Vinayak Holikatti <vinholika...@gmail.com> Cc: Subhash Jadavani <subha...@codeaurora.org> Cc: Dolev Raviv <dra...@codeaurora.org> Cc: Sujit Reddy Thumma <sthu...@codeaurora.org> Cc: Yaniv Gardi <yga...@codeaurora.org> Cc: Christoph Hellwig <h...@lst.de> Cc: "James E.J. Bottomley" <jbottom...@parallels.com> Cc: linux-scsi@vger.kernel.org --- drivers/scsi/ufs/ufshcd.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 59b6544..d18adc4 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4248,12 +4248,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); } -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html