Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit edae206c authored by Umang Agrawal's avatar Umang Agrawal Committed by Gerrit - the friendly Code Review server
Browse files

power: smbcharger: Fix null pointer dereference error



Fix to prevent null pointer dereference error in the led brightness
set function by an initial check to determine whether the
power_supply structure is defined or not.

Change-Id: I09f793630c2ce98caa4a2c1b711bf7a4a9bd4eb5
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent 1f63f878
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -4043,6 +4043,11 @@ static void smbchg_chg_led_brightness_set(struct led_classdev *cdev,
	u8 reg;
	int rc;

	if (!is_bms_psy_present(chip)) {
		dev_err(chip->dev, "Couldn't access bms psy\n");
		return;
	}

	reg = (value > LED_OFF) ? CHG_LED_ON << CHG_LED_SHIFT :
		CHG_LED_OFF << CHG_LED_SHIFT;
	pval.intval = value > LED_OFF ? 1 : 0;
@@ -4090,6 +4095,11 @@ static void smbchg_chg_led_blink_set(struct smbchg_chip *chip,
	u8 reg;
	int rc;

	if (!is_bms_psy_present(chip)) {
		dev_err(chip->dev, "Couldn't access bms psy\n");
		return;
	}

	pval.intval = (blinking == 0) ? 0 : 1;
	power_supply_set_property(chip->bms_psy, POWER_SUPPLY_PROP_HI_POWER,
			&pval);