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

Commit f2061da6 authored by Ashish Chavan's avatar Ashish Chavan
Browse files

power: smb1398: Fix array index out of bounds error



In smb1398_get_irq_index_byname() while accessing 'smb_irqs' we
may cause array index out of bound error. Fix this by looping
till ARRAY_SIZE(smb_irqs) instead of NUM_IRQS.

While at it also fix usage of uninitialized variable of 'main_fcc_ua'.

Change-Id: I2f726cdc23fdbff431d48699c8407744dd0ca93e
Signed-off-by: default avatarAshish Chavan <ashichav@codeaurora.org>
parent c1fcceff
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1528,7 +1528,7 @@ static int smb1398_get_irq_index_byname(const char *irq_name)
{
	int i;

	for (i = 0; i < NUM_IRQS; i++) {
	for (i = 0; i < ARRAY_SIZE(smb_irqs); i++) {
		if (smb_irqs[i].name != NULL)
			if (strcmp(smb_irqs[i].name, irq_name) == 0)
				return i;
@@ -1784,7 +1784,7 @@ static void smb1398_taper_work(struct work_struct *work)
	struct smb1398_chip *chip = container_of(work,
			struct smb1398_chip, taper_work);
	union power_supply_propval pval = {0};
	int rc, fcc_ua, fv_uv, stepper_ua, main_fcc_ua, min_ilim_ua;
	int rc, fcc_ua, fv_uv, stepper_ua, main_fcc_ua = 0, min_ilim_ua;
	bool slave_en;

	if (!is_psy_voter_available(chip))