Skip to contentSkip to conversation

remoteproc: Assorted bug fixes across remoteproc core and drivers

PATCH New Lee Jones 1 participant 11 messages Nov 23

Subsystems (4)
lore
Share & tools
lore

Lee Jones

author
#0 lore raw

cover remoteproc: Assorted bug fixes across remoteproc core and drivers

These issues were reported by Sashiko.

None of these changes have been tested on physical hardware.

Cc "Rob Herring (Arm)" <[email protected]>
Cc "Sjur Brændeland" <[email protected]>
Cc Alex Elder <[email protected]>
Cc Andrew Davis <[email protected]>
Cc Beleswar Padhi <[email protected]>
Cc Bjorn Andersson <[email protected]>
Cc Brian Swetland <[email protected]>
Cc Clement Leger <[email protected]>
Cc Daniel Baluta <[email protected]>
Cc De Leon <[email protected]>
Cc Fabio Estevam <[email protected]>
Cc Frank Li <[email protected]>
Cc Guzman Lugo <[email protected]>
Cc Hari Kanigeri <[email protected]>
Cc Hari Nagalla <[email protected]>
Cc HyeongJun An <[email protected]>
Cc Iuliana Prodan <[email protected]>
Cc Loic Pallardy <[email protected]>
Cc Mark Grosen <[email protected]>
Cc Mathieu Poirier <[email protected]>
Cc Ohad Ben-Cohen <[email protected]>
Cc Oleksij Rempel <[email protected]>
Cc Peng Fan <[email protected]>
Cc Pengutronix Kernel Team <[email protected]>
Cc Rishabh Bhatnagar <[email protected]>
Cc Robert Tivy <[email protected]>
Cc Sascha Hauer <[email protected]>
Cc Shengjiu Wang <[email protected]>
Cc Siddharth Gupta <[email protected]>
Cc Suman Anna <[email protected]>
Cc Tero Kristo <[email protected]>
Cc Uday Khare <[email protected]>

Lee Jones (10):
remoteproc: core: Fix integer overflow in rproc_check_carveout_da()
remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va()
remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va()
remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments()
remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure
remoteproc: imx_rproc: Register SCU cleanup after resource acquisition
remoteproc: qcom: Clear glink->node on allocation failure
remoteproc: qcom: Skip unregistering uninitialised SSR subdevice
remoteproc: imx_dsp_rproc: Fix pointer stride in
imx_dsp_rproc_memset()
remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes

 drivers/remoteproc/imx_dsp_rproc.c         | 10 ++++---
 drivers/remoteproc/imx_rproc.c             | 33 ++++++++++++++--------
 drivers/remoteproc/omap_remoteproc.c       | 11 +++++---
 drivers/remoteproc/qcom_common.c           |  5 ++++
 drivers/remoteproc/remoteproc_core.c       |  7 ++---
 drivers/remoteproc/remoteproc_elf_loader.c |  6 ++--
 drivers/remoteproc/ti_k3_common.c          | 27 +++++++++++-------
 7 files changed, 61 insertions(+), 38 deletions(-)
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#1 lore raw

PATCH 1/10 remoteproc: core: Fix integer overflow in rproc_check_carveout_da()

rproc_check_carveout_da() subtracts two unsigned 32-bit device addresses and stores the difference in a signed int variable before checking the carveout bounds. When da exceeds mem->da by 0x80000000 or more, delta wraps negative; conversely, when da is less than mem->da by more than 0x80000000, delta wraps to a positive integer and bypasses the lower bound check. Furthermore, delta + len is evaluated in 32-bit unsigned arithmetic before promotion to size_t, allowing large da and len values to wrap around 32 bits and bypass the upper bound check as well.

Since len > mem->len is already rejected upfront, compare da < mem->da directly and check da - mem->da > mem->len - len using subtraction to eliminate signedness bugs and integer wraparound.

Fixes c874bf59add0 ("remoteproc: add helper function to check carveout device address")
---
 drivers/remoteproc/remoteproc_core.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
drivers/remoteproc/remoteproc_core.c +2 -5
index 23f8539a99bd..2b2ebf39a40a 100644
@@ -287,7 +287,6 @@ static int rproc_check_carveout_da(struct rproc *rproc,
 				   struct rproc_mem_entry *mem, u32 da, u32 len)
 {
 	struct device *dev = &rproc->dev;
-	int delta;
 
 	/* Check requested resource length */
 	if (len > mem->len) {
@@ -299,16 +298,14 @@ static int rproc_check_carveout_da(struct rproc *rproc,
 		/* Address doesn't match registered carveout configuration */
 		return -EINVAL;
 	} else if (da != FW_RSC_ADDR_ANY && mem->da != FW_RSC_ADDR_ANY) {
-		delta = da - mem->da;
-
 		/* Check requested resource belongs to registered carveout */
-		if (delta < 0) {
+		if (da < mem->da) {
 			dev_err(dev,
 				"Registered carveout doesn't fit da request\n");
 			return -EINVAL;
 		}
 
-		if (delta + len > mem->len) {
+		if (da - mem->da > mem->len - len) {
 			dev_err(dev,
 				"Registered carveout doesn't fit len request\n");
 			return -EINVAL;
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#2 lore raw

PATCH 2/10 remoteproc: k3: Fix integer overflow in k3_rproc_da_to_va()

In reply to Lee Jones

k3_rproc_da_to_va() validates memory regions using (da + len) <= (base + size) and stores da - base in a 32-bit unsigned offset variable. Because da is u64 and len is size_t, a malformed firmware segment or resource entry with a large da value causes da + len to wrap around 64 bits and pass the upper bound check. Subsequent assignment to the u32 offset variable truncates the 64-bit difference, returning an out-of-bounds kernel virtual address to callers such as the ELF segment loader.

Widen offset to u64 and rewrite the range checks across all three memory loops using overflow-safe subtraction.

Fixes 9179f8bfa98d ("remoteproc: k3: Refactor .da_to_va rproc ops into common driver")
---
 drivers/remoteproc/ti_k3_common.c | 27 +++++++++++++++++----------
 1 file changed, 17 insertions(+), 10 deletions(-)
drivers/remoteproc/ti_k3_common.c +17 -10
index f79ccb57a372..1d06f46b75c6 100644
@@ -356,7 +356,8 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
 	struct k3_rproc *kproc = rproc->priv;
 	void __iomem *va = NULL;
 	phys_addr_t bus_addr;
-	u32 dev_addr, offset;
+	u32 dev_addr;
+	u64 offset;
 	size_t size;
 	int i;
 
@@ -369,17 +370,21 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
 		size = kproc->mem[i].size;
 
 		/* handle rproc-view addresses */
-		if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+		if (da >= dev_addr) {
 			offset = da - dev_addr;
-			va = kproc->mem[i].cpu_addr + offset;
-			return (__force void *)va;
+			if (offset <= size && len <= size - offset) {
+				va = kproc->mem[i].cpu_addr + offset;
+				return (__force void *)va;
+			}
 		}
 
 		/* handle SoC-view addresses */
-		if (da >= bus_addr && (da + len) <= (bus_addr + size)) {
+		if (da >= bus_addr) {
 			offset = da - bus_addr;
-			va = kproc->mem[i].cpu_addr + offset;
-			return (__force void *)va;
+			if (offset <= size && len <= size - offset) {
+				va = kproc->mem[i].cpu_addr + offset;
+				return (__force void *)va;
+			}
 		}
 	}
 
@@ -388,10 +393,12 @@ void *k3_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *is_iomem)
 		dev_addr = kproc->rmem[i].dev_addr;
 		size = kproc->rmem[i].size;
 
-		if (da >= dev_addr && ((da + len) <= (dev_addr + size))) {
+		if (da >= dev_addr) {
 			offset = da - dev_addr;
-			va = kproc->rmem[i].cpu_addr + offset;
-			return (__force void *)va;
+			if (offset <= size && len <= size - offset) {
+				va = kproc->rmem[i].cpu_addr + offset;
+				return (__force void *)va;
+			}
 		}
 	}
 
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#3 lore raw

PATCH 3/10 remoteproc: omap: Fix integer overflow in omap_rproc_da_to_va()

In reply to Lee Jones

omap_rproc_da_to_va() checks da + len <= dev_addr + size using 64-bit unsigned addition and stores da - dev_addr in a 32-bit unsigned offset variable. A crafted firmware segment or resource entry with a large da value can wrap da + len around 64 bits, bypassing the upper bound check, while truncating da - dev_addr to 32 bits yields an out-of-bounds pointer offset into kernel memory.

Widen offset to u64 and validate both offset <= size and len <= size - offset without addition overflow.

Fixes 530a1b57e859 ("remoteproc/omap: Add the rproc ops .da_to_va() implementation")
---
 drivers/remoteproc/omap_remoteproc.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/remoteproc/omap_remoteproc.c +7 -4
index f52a531877ae..573f8d9ae8eb 100644
@@ -735,7 +735,7 @@ static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *
 {
 	struct omap_rproc *oproc = rproc->priv;
 	int i;
-	u32 offset;
+	u64 offset;
 
 	if (len <= 0)
 		return NULL;
@@ -744,9 +744,12 @@ static void *omap_rproc_da_to_va(struct rproc *rproc, u64 da, size_t len, bool *
 		return NULL;
 
 	for (i = 0; i < oproc->num_mems; i++) {
-		if (da >= oproc->mem[i].dev_addr && da + len <=
-		    oproc->mem[i].dev_addr + oproc->mem[i].size) {
-			offset = da - oproc->mem[i].dev_addr;
+		if (da < oproc->mem[i].dev_addr)
+			continue;
+
+		offset = da - oproc->mem[i].dev_addr;
+		if (offset <= oproc->mem[i].size &&
+		    len <= oproc->mem[i].size - offset) {
 			/* __force to make sparse happy with type conversion */
 			return (__force void *)(oproc->mem[i].cpu_addr +
 						offset);
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#4 lore raw

PATCH 4/10 remoteproc: elf_loader: Fix overflow in rproc_elf_load_segments()

In reply to Lee Jones

For 64-bit ELF firmware images, rproc_elf_load_segments() reads 64-bit p_offset and p_filesz fields and checks offset + filesz > fw->size. A malformed segment header where offset + filesz wraps around 64 bits bypasses this truncation check, causing the subsequent segment copy from elf_data + offset to read out of bounds outside the firmware buffer.

Replace the addition with an overflow-safe subtraction check and log offset and filesz individually when rejecting a truncated image.

Fixes f31e339f1b9b ("remoteproc: Add elf64 support in elf loader")
---
 drivers/remoteproc/remoteproc_elf_loader.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/remoteproc/remoteproc_elf_loader.c +3 -3
index da3cddbe7d4c..6b9de0627768 100644
@@ -213,9 +213,9 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw)
 			break;
 		}
 
-		if (offset + filesz > fw->size) {
-			dev_err(dev, "truncated fw: need 0x%llx avail 0x%zx\n",
-				offset + filesz, fw->size);
+		if (offset > fw->size || filesz > fw->size - offset) {
+			dev_err(dev, "truncated fw: offset 0x%llx filesz 0x%llx avail 0x%zx\n",
+				offset, filesz, fw->size);
 			ret = -EINVAL;
 			break;
 		}
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#5 lore raw

PATCH 5/10 remoteproc: imx_rproc: Avoid stale mailbox pointers on request failure

In reply to Lee Jones

imx_rproc_xtr_mbox_init() stores the result of mbox_request_channel_byname() directly into priv->tx_ch and priv->rx_ch. Because mailbox channels are freed on stop() and detach() and re-requested on start(), attach(), and system shutdown, a failure while requesting "tx" leaves an ERR_PTR in priv->tx_ch, which is later dereferenced by imx_rproc_kick() and imx_rproc_free_mbox(). If "rx" fails after "tx" succeeds, priv->tx_ch is freed without being cleared while priv->rx_ch retains an ERR_PTR, causing subsequent calls to see both pointers as non-NULL and skip initialisation, leading to a use-after-free on priv->tx_ch and an ERR_PTR dereference on priv->rx_ch.

Request both channels into local variables and assign priv->tx_ch and priv->rx_ch only after both requests succeed.

Fixes 99b142cf7191 ("remoteproc: imx_rproc: Request mbox channel later")
---
 drivers/remoteproc/imx_rproc.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/remoteproc/imx_rproc.c +11 -7
index 581bb07f5893..a77a3342e1ed 100644
@@ -875,6 +875,7 @@ static void imx_rproc_rx_callback(struct mbox_client *cl, void *msg)
 static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)
 {
 	struct imx_rproc *priv = rproc->priv;
+	struct mbox_chan *tx_ch, *rx_ch;
 	struct device *dev = priv->dev;
 	struct mbox_client *cl;
 
@@ -900,18 +901,21 @@ static int imx_rproc_xtr_mbox_init(struct rproc *rproc, bool tx_block)
 	cl->knows_txdone = false;
 	cl->rx_callback = imx_rproc_rx_callback;
 
-	priv->tx_ch = mbox_request_channel_byname(cl, "tx");
-	if (IS_ERR(priv->tx_ch))
-		return dev_err_probe(cl->dev, PTR_ERR(priv->tx_ch),
+	tx_ch = mbox_request_channel_byname(cl, "tx");
+	if (IS_ERR(tx_ch))
+		return dev_err_probe(cl->dev, PTR_ERR(tx_ch),
 				     "failed to request tx mailbox channel\n");
 
-	priv->rx_ch = mbox_request_channel_byname(cl, "rx");
-	if (IS_ERR(priv->rx_ch)) {
-		mbox_free_channel(priv->tx_ch);
-		return dev_err_probe(cl->dev, PTR_ERR(priv->rx_ch),
+	rx_ch = mbox_request_channel_byname(cl, "rx");
+	if (IS_ERR(rx_ch)) {
+		mbox_free_channel(tx_ch);
+		return dev_err_probe(cl->dev, PTR_ERR(rx_ch),
 				     "failed to request rx mailbox channel\n");
 	}
 
+	priv->tx_ch = tx_ch;
+	priv->rx_ch = rx_ch;
+
 	return 0;
 }
 
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#6 lore raw

PATCH 6/10 remoteproc: imx_rproc: Register SCU cleanup after resource acquisition

In reply to Lee Jones

imx_rproc_scu_api_detect_mode() registers the imx_rproc_put_scu() devres cleanup action before attaching power domains or registering the SCU partition reboot notifier and enabling its interrupt group. If imx_sc_rm_get_resource_owner() or imx_scu_irq_register_notifier() fails, imx_rproc_put_scu() runs during failure unwind and unregisters an unregistered notifier block while disabling an unconfigured interrupt bit. Worse, if imx_scu_irq_group_enable() fails, the error path explicitly unregisters priv->rproc_nb and devres subsequently invokes imx_rproc_put_scu() to unregister the same notifier block a second time.

Defer devm_add_action_or_reset() until power-domain attachment or SCU notifier and interrupt setup have completed.

Fixes 9b2451658afa ("remoteproc: imx_rproc: Use devm_add_action_or_reset() for scu cleanup")
---
 drivers/remoteproc/imx_rproc.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)
drivers/remoteproc/imx_rproc.c +10 -5
index a77a3342e1ed..9ff2cd50acb6 100644
@@ -1083,10 +1083,6 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 	else
 		priv->core_index = 0;
 
-	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
-	if (ret)
-		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
-
 	/*
 	 * If Mcore resource is not owned by Acore partition, It is kicked by ROM,
 	 * and Linux could only do IPC with Mcore and nothing else.
@@ -1095,7 +1091,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		if (of_property_read_u32(dev->of_node, "fsl,entry-address", &priv->entry))
 			return -EINVAL;
 
-		return imx_rproc_attach_pd(priv);
+		ret = imx_rproc_attach_pd(priv);
+		if (ret)
+			return ret;
+
+		goto add_scu_action;
 	}
 
 	priv->rproc->state = RPROC_DETACHED;
@@ -1126,6 +1126,11 @@ static int imx_rproc_scu_api_detect_mode(struct rproc *rproc)
 		return ret;
 	}
 
+add_scu_action:
+	ret = devm_add_action_or_reset(dev, imx_rproc_put_scu, priv);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to add action for put scu\n");
+
 	return 0;
 }
 
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#7 lore raw

PATCH 7/10 remoteproc: qcom: Clear glink->node on allocation failure

In reply to Lee Jones

When kstrdup_const() fails in qcom_add_glink_subdev(), the error path drops the device-node reference via of_node_put(glink->node) and returns before registering the GLINK subdevice, leaving glink->node non-NULL. During subsequent teardown, qcom_remove_glink_subdev() checks glink->node, calls rproc_remove_subdev() on an uninitialised list node resulting in a NULL pointer dereference, and drops the device-node reference a second time.

Reset glink->node to NULL when releasing the node reference so teardown leaves an unregistered subdevice untouched.

Fixes 44f4911ab8e6 ("remoteproc: qcom: Fix glink->node reference leak in qcom_add_glink_subdev")
---
 drivers/remoteproc/qcom_common.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/remoteproc/qcom_common.c +2 -0
index 5294e327f158..c53190f0c537 100644
@@ -255,6 +255,7 @@ void qcom_add_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glink,
 	glink->ssr_name = kstrdup_const(ssr_name, GFP_KERNEL);
 	if (!glink->ssr_name) {
 		of_node_put(glink->node);
+		glink->node = NULL;
 		return;
 	}
 
@@ -280,6 +281,7 @@ void qcom_remove_glink_subdev(struct rproc *rproc, struct qcom_rproc_glink *glin
 	rproc_remove_subdev(rproc, &glink->subdev);
 	kfree_const(glink->ssr_name);
 	of_node_put(glink->node);
+	glink->node = NULL;
 }
 EXPORT_SYMBOL_GPL(qcom_remove_glink_subdev);
 
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#8 lore raw

PATCH 8/10 remoteproc: qcom: Skip unregistering uninitialised SSR subdevice

In reply to Lee Jones

If qcom_ssr_get_subsys() fails in qcom_add_ssr_subdev(), the function logs an error and returns early without calling rproc_add_subdev(), leaving ssr->info NULL and ssr->subdev.node uninitialised. When driver probe unwinds or the device is later removed, qcom_remove_ssr_subdev() unconditionally calls rproc_remove_subdev(), dereferencing a NULL list pointer in list_del().

Guard qcom_remove_ssr_subdev() on ssr->info being non-NULL, matching the GLINK and SMD subdevice teardown helpers.

Fixes 5abfe5cf0b83 ("remoteproc: qcom: Add per subsystem SSR notification")
---
 drivers/remoteproc/qcom_common.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/remoteproc/qcom_common.c +3 -0
index c53190f0c537..6fd92c33392b 100644
@@ -537,6 +537,9 @@ EXPORT_SYMBOL_GPL(qcom_add_ssr_subdev);
  */
 void qcom_remove_ssr_subdev(struct rproc *rproc, struct qcom_rproc_ssr *ssr)
 {
+	if (!ssr->info)
+		return;
+
 	rproc_remove_subdev(rproc, &ssr->subdev);
 	ssr->info = NULL;
 }
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#9 lore raw

PATCH 9/10 remoteproc: imx_dsp_rproc: Fix pointer stride in imx_dsp_rproc_memset()

In reply to Lee Jones

Commit 3c497f624d40 ("remoteproc: imx_dsp_rproc: Fix kernel test robot sparse warning") changed tmp_dst from u32 * to void __iomem *. In GNU C, incrementing a void pointer advances it by 1 byte rather than 4 bytes. Consequently, the word-fill loop in imx_dsp_rproc_memset() steps by 1 byte per 32-bit writel(), triggering unaligned 32-bit MMIO accesses on Device-mapped DSP IRAM, mispositioning tmp_dst for the trailing-byte read-modify-write, and leaving roughly three quarters of the target region uninitialised.

Advance tmp_dst by 4 bytes per 32-bit word write.

Fixes 3c497f624d40 ("remoteproc: imx_dsp_rproc: Fix kernel test robot sparse warning")
---
 drivers/remoteproc/imx_dsp_rproc.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +4 -2
index 96d619daf3f5..2771043ee433 100644
@@ -843,8 +843,10 @@ static int imx_dsp_rproc_memset(void *addr, u8 value, size_t size)
 	q = size / 4;
 	r = size % 4;
 
-	while (q--)
-		writel(tmp_val, tmp_dst++);
+	while (q--) {
+		writel(tmp_val, tmp_dst);
+		tmp_dst += 4;
+	}
 
 	if (r) {
 		affected_mask = GENMASK(8 * r, 0);
Signature · 1 line
2.56.1.750.gf70dc682cf-goog
author
#10 lore raw

PATCH 10/10 remoteproc: imx_dsp_rproc: Fix off-by-one bitmask for trailing bytes

In reply to Lee Jones

When size is not a multiple of 4, both imx_dsp_rproc_memcpy() and imx_dsp_rproc_memset() compute affected_mask as GENMASK(8 * r, 0) for the remaining r bytes (1 <= r <= 3). Because GENMASK(h, l) is inclusive of bit h, GENMASK(8 * r, 0) sets 8 * r + 1 bits and clears or overwrites the least-significant bit of the first byte past the end of the target region during the 32-bit read-modify-write.

Use GENMASK(8 * r - 1, 0) to mask exclusively the r trailing bytes.

Fixes 408ec1ff0caa ("remoteproc: imx_dsp_rproc: Add custom memory copy implementation for i.MX DSP Cores")
---
 drivers/remoteproc/imx_dsp_rproc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/remoteproc/imx_dsp_rproc.c +2 -2
index 2771043ee433..0e0325d5df9f 100644
@@ -799,7 +799,7 @@ static int imx_dsp_rproc_memcpy(void *dst, const void *src, size_t size)
 		writel(source[i], dest + i * 4);
 
 	if (r) {
-		affected_mask = GENMASK(8 * r, 0);
+		affected_mask = GENMASK(8 * r - 1, 0);
 
 		/*
 		 * first read the 32bit data of dest, then change affected
@@ -849,7 +849,7 @@ static int imx_dsp_rproc_memset(void *addr, u8 value, size_t size)
 	}
 
 	if (r) {
-		affected_mask = GENMASK(8 * r, 0);
+		affected_mask = GENMASK(8 * r - 1, 0);
 
 		/*
 		 * first read the 32bit data of addr, then change affected
Signature · 1 line
2.56.1.750.gf70dc682cf-goog