Skip to contentSkip to conversation

drivers: scsi: ufs: Fix possible null derefrence

PATCH In review Tapasweni Pathak 2 participants 2 messages Mar 4, 2015 – Mar 10, 2015 SCSI

lore
Share & tools
lore
#0 lore raw

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.

---
 drivers/scsi/ufs/ufshcd.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +5 -2
index 5d60a86..c54e64f 100644
@@ -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

#1 lore raw
Quoted 16 lines

Check for null before being dereferenced to avoid a invalid null dereference.

Found using Coccinelle.

---
 drivers/scsi/ufs/ufshcd.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/ufs/ufshcd.c +0 -0
index 5d60a86..c54e64f 100644

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