drivers: scsi: ufs: Fix possible null derefrence
PATCH 1/1 drivers: scsi: ufs: Fix possible null derefrence
Check for null before being dereferenced to avoid a invalid null dereference.
Found using Coccinelle.
Signed-off-by Tapasweni Pathak <[email protected]>
Acked-by Julia Lawall <[email protected]>
--- drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +5 -2
@@ -4268,12 +4268,15 @@ static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { int ret = 0; -struct regulator *reg = vreg->reg; -const char *name = vreg->name; +struct regulator *reg; +const char *name;int min_uV, uA_load;BUG_ON (!vreg); + reg = vreg->reg; + name = vreg->name; +if (regulator_count_voltages (reg) >0 ) { min_uV = on ? vreg->min_uV :0 ; ret =regulator_set_voltage (reg, min_uV, vreg->max_uV);
--
1.7.9.5
Quoted 16 lines
Check for null before being dereferenced to avoid a invalid null dereference.
Found using Coccinelle.
Signed-off-by Tapasweni Pathak <[email protected]>Acked-by Julia Lawall <[email protected]>--- drivers/scsi/ufs/ufshcd.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)drivers/scsi/ufs/ufshcd.c +0
-0
drivers/scsi/ufs/ufshcd.c static int ufshcd_config_vreg(struct device *dev, · line 4275
Quoted 10 lines
drivers/scsi/ufs/ufshcd.c +2
-2@@ -4268,12 +4268,15 @@ static int ufshcd_config_vreg(struct device *dev, struct ufs_vreg *vreg, bool on) { int ret = 0; -struct regulator *reg = vreg->reg; -const char *name = vreg->name; +struct regulator *reg; +const char *name;int min_uV, uA_load;BUG_ON (!vreg);
Please add to the patch fix for another instance of this in ufshcd_config_vreg_load():
static int ufshcd_config_vreg_load(struct device *dev,
struct ufs_vreg *vreg, int ua)
{
int ret = 0;
struct regulator *reg = vreg->reg;
const char *name = vreg->name;
BUG_ON(!vreg);Gilad.
Signature · 3 lines
Qualcomm Israel, on behalf of Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project