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

Commit 2d41a577 authored by Umang Agrawal's avatar Umang Agrawal
Browse files

power: qpnp-charger: 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.

CRs-Fixed: 2166164
Change-Id: Ifcd6e55aa78c4c4d4dc539ac6ffe67263d198b47
Signed-off-by: default avatarUmang Agrawal <uagrawal@codeaurora.org>
parent f38ea00b
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -4243,10 +4243,12 @@ static void smbchg_chg_led_brightness_set(struct led_classdev *cdev,
	reg = (value > LED_OFF) ? CHG_LED_ON << CHG_LED_SHIFT :
		CHG_LED_OFF << CHG_LED_SHIFT;

	if (chip->bms_psy) {
		if (value > LED_OFF)
			power_supply_set_hi_power_state(chip->bms_psy, 1);
		else
			power_supply_set_hi_power_state(chip->bms_psy, 0);
	}

	pr_smb(PR_STATUS,
			"set the charger led brightness to value=%d\n",
@@ -4289,11 +4291,16 @@ static void smbchg_chg_led_blink_set(struct smbchg_chip *chip,
	u8 reg;
	int rc;

	if (chip->bms_psy) {
		if (blinking == 0)
			power_supply_set_hi_power_state(chip->bms_psy, 0);
		else
			power_supply_set_hi_power_state(chip->bms_psy, 1);
	}

	if (blinking == 0) {
		reg = CHG_LED_OFF << CHG_LED_SHIFT;
		power_supply_set_hi_power_state(chip->bms_psy, 0);
	} else {
		power_supply_set_hi_power_state(chip->bms_psy, 1);
		if (blinking == 1)
			reg = LED_BLINKING_PATTERN2 << CHG_LED_SHIFT;
		else if (blinking == 2)