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

Commit 02a4a1c2 authored by Kuirong Wang's avatar Kuirong Wang
Browse files

ASoC: wcd9xxx: Add check for array boundary



This is possible the index for the array irq_marks_cur out of
array boundary. Add the check to assure the index for the array
irq_marks_cur within boundary.

Change-Id: I13d56d54c5439fd65a33946c40e4c0bdecbe070e
CRs-fixed: 714763
Signed-off-by: default avatarKuirong Wang <kuirongw@codeaurora.org>
parent e4b5be8f
Loading
Loading
Loading
Loading
+18 −4
Original line number Diff line number Diff line
@@ -103,8 +103,15 @@ static void wcd9xxx_irq_enable(struct irq_data *data)
	struct wcd9xxx_core_resource *wcd9xxx_res =
			irq_data_get_irq_chip_data(data);
	int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
	wcd9xxx_res->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)] &=
	int byte = BIT_BYTE(wcd9xxx_irq);
	int size = ARRAY_SIZE(wcd9xxx_res->irq_masks_cur);
	if ((byte < size) && (byte >= 0)) {
		wcd9xxx_res->irq_masks_cur[byte] &=
			~(BYTE_BIT_MASK(wcd9xxx_irq));
	} else {
		pr_err("%s: Array size is %d but index is %d: Out of range\n",
			__func__, size, byte);
	}
}

static void wcd9xxx_irq_disable(struct irq_data *data)
@@ -112,8 +119,15 @@ static void wcd9xxx_irq_disable(struct irq_data *data)
	struct wcd9xxx_core_resource *wcd9xxx_res =
			irq_data_get_irq_chip_data(data);
	int wcd9xxx_irq = virq_to_phyirq(wcd9xxx_res, data->irq);
	wcd9xxx_res->irq_masks_cur[BIT_BYTE(wcd9xxx_irq)]
	int byte = BIT_BYTE(wcd9xxx_irq);
	int size = ARRAY_SIZE(wcd9xxx_res->irq_masks_cur);
	if ((byte < size) && (byte >= 0)) {
		wcd9xxx_res->irq_masks_cur[byte]
			|= BYTE_BIT_MASK(wcd9xxx_irq);
	} else {
		pr_err("%s: Array size is %d but index is %d: Out of range\n",
			__func__, size, byte);
	}
}

static void wcd9xxx_irq_mask(struct irq_data *d)