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

Commit 7863fbab authored by Gaurav Kohli's avatar Gaurav Kohli Committed by Lingutla Chandrasekhar
Browse files

drivers: llcc: Add extra check for sct size during get slice call



There could be a potential out of bound access to the sct table, if
client calls get slice with not supported slice id.
So to avoid the same check the size of sct table to traverse and
return error in case slice id is not present.

Change-Id: I39f4a61dd46e0e8b65b827b63073e1d6f0f2ca24
Signed-off-by: default avatarGaurav Kohli <gkohli@codeaurora.org>
parent acbd53b4
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -80,6 +80,7 @@ static struct llcc_slice_desc *llcc_slice_get_entry(struct device *dev, int n)
	const struct llcc_slice_config *llcc_data_ptr;
	struct llcc_slice_desc *desc;
	struct platform_device *pdev;
	u32 sz, count;

	if (of_parse_phandle_with_args(dev->of_node, "cache-slices",
				       "#cache-cells", n, &phargs)) {
@@ -100,14 +101,17 @@ static struct llcc_slice_desc *llcc_slice_get_entry(struct device *dev, int n)
	}

	llcc_data_ptr = drv->slice_data;
	sz = drv->llcc_config_data_sz;
	count = 0;

	while (llcc_data_ptr) {
	while (llcc_data_ptr && count < sz) {
		if (llcc_data_ptr->usecase_id == phargs.args[0])
			break;
		llcc_data_ptr++;
		count++;
	}

	if (llcc_data_ptr == NULL) {
	if (llcc_data_ptr == NULL || count == sz) {
		pr_err("can't find %d usecase id\n", phargs.args[0]);
		return ERR_PTR(-ENODEV);
	}