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

Commit 688cf0d3 authored by Subbaraman Narayanamurthy's avatar Subbaraman Narayanamurthy
Browse files

power: qpnp-fg-gen3: Whitelist the values in profile integrity word



While checking the profile integrity word to determine whether a
profile load is required or not, whitelist the values so that
profile loading cannot be skipped because of a garbage value
present.

Change-Id: Iff1d116541d07dbb39de966d98fa69b76aeab93d
Signed-off-by: default avatarSubbaraman Narayanamurthy <subbaram@codeaurora.org>
parent 30e3afea
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -2209,6 +2209,17 @@ static bool is_profile_load_required(struct fg_chip *chip)
	/* Check if integrity bit is set */
	if (val & PROFILE_LOAD_BIT) {
		fg_dbg(chip, FG_STATUS, "Battery profile integrity bit is set\n");

		/* Whitelist the values */
		val &= ~PROFILE_LOAD_BIT;
		if (val != HLOS_RESTART_BIT && val != BOOTLOADER_LOAD_BIT &&
			val != (BOOTLOADER_LOAD_BIT | BOOTLOADER_RESTART_BIT)) {
			val |= PROFILE_LOAD_BIT;
			pr_warn("Garbage value in profile integrity word: 0x%x\n",
				val);
			return true;
		}

		rc = fg_sram_read(chip, PROFILE_LOAD_WORD, PROFILE_LOAD_OFFSET,
				buf, PROFILE_COMP_LEN, FG_IMA_DEFAULT);
		if (rc < 0) {