Skip to contentSkip to conversation

Fix CVEs related to patches backported to the CIP kernel

PATCH Applied Nobuhiro Iwamatsu 3 participants 12 messages Oct 26 – Oct 27

Subsystems (7)
IIO dmaengine I3C Counter +3 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Fix CVEs related to patches backported to the CIP kernel

Hi all,

This is a patch series that fixes CVEs related to patches backported to CIP kernel.
The following CVEs and commits are addressed in this:

- CVE-2026-53030:
introduced-commits:
- 0bea5c0e39992654677bb6e94d276c14bf75c2f8
- CVE-2025-71187:
introduced-commits:
- 282d5dfb9147694b8ba1a6528d38450d2f7addda
- CVE-2025-39774:
introduced-commits:
- ffe4a44bf16c17a26124536533179c12239668de
- CVE-2026-31740:
introduced-commits:
- 6ae52685cb60989ed37870bb7f9d2e2d96a6e509
- CVE-2026-31741:
introduced-commits:
- 6ae52685cb60989ed37870bb7f9d2e2d96a6e509

Best regards,
Nobuhiro

Claudiu Beznea (1):
iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Cosmin Tanislav (2):
counter: rz-mtu3-cnt: prevent counter from being toggled multiple
times
counter: rz-mtu3-cnt: do not use struct rz_mtu3_channel's dev member

Felix Gu (1):
i3c: master: renesas: Fix memory leak in renesas_i3c_i3c_xfers()

Johan Hovold (1):
dmaengine: sh: rz-dmac: fix device leak on probe failure

 drivers/counter/rz-mtu3-cnt.c    | 67 +++++++++++++++++---------------
 drivers/dma/sh/rz-dmac.c         | 13 ++++++-
 drivers/i3c/master/renesas-i3c.c |  4 +-
 drivers/iio/adc/rzg2l_adc.c      |  4 +-
 4 files changed, 50 insertions(+), 38 deletions(-)
Signature · 1 line
2.55.0
#1 lore raw

PATCH 1/5 i3c: master: renesas: Fix memory leak in renesas_i3c_i3c_xfers()

From: Felix Gu <[email protected]>

commit d7665c3b4f575251e449e2656879392346ca612b upstream.

The xfer structure allocated by renesas_i3c_alloc_xfer() was never freed in the renesas_i3c_i3c_xfers() function. Use the __free(kfree) cleanup attribute to automatically free the memory when the variable goes out of scope.

---
 drivers/i3c/master/renesas-i3c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/i3c/master/renesas-i3c.c +2 -2
index 2086a3ff016eea..16c9b54057a9ef 100644
@@ -8,6 +8,7 @@
 
 #include <linux/bitfield.h>
 #include <linux/bitops.h>
+#include <linux/cleanup.h>
 #include <linux/clk.h>
 #include <linux/completion.h>
 #include <linux/err.h>
@@ -818,13 +819,12 @@ static int renesas_i3c_priv_xfers(struct i3c_dev_desc *dev, struct i3c_priv_xfer
 	struct i3c_master_controller *m = i3c_dev_get_master(dev);
 	struct renesas_i3c *i3c = to_renesas_i3c(m);
 	struct renesas_i3c_i2c_dev_data *data = i3c_dev_get_master_data(dev);
-	struct renesas_i3c_xfer *xfer;
 	int i;
 
 	/* Enable I3C bus. */
 	renesas_i3c_bus_enable(m, true);
 
-	xfer = renesas_i3c_alloc_xfer(i3c, 1);
+	struct renesas_i3c_xfer *xfer __free(kfree) = renesas_i3c_alloc_xfer(i3c, 1);
 	if (!xfer)
 		return -ENOMEM;
 
Signature · 1 line
2.55.0
Reviewed-by on v1 1/5
#2 lore raw

Re: [cip-dev] [PATCH 6.1.y-cip 1/5] i3c: master: renesas: Fix memory leak in renesas_i3c_i3c_xfers()

Quoted 9 lines · Nobuhiro Iwamatsu via lists.cip-project.org

From: Felix Gu<[email protected]>

commit d7665c3b4f575251e449e2656879392346ca612b upstream.

The xfer structure allocated by renesas_i3c_alloc_xfer() was never freed in the renesas_i3c_i3c_xfers() function. Use the __free(kfree) cleanup attribute to automatically free the memory when the variable goes out of scope.

Quoted 8 lines
#3 lore raw

PATCH 2/5 dmaengine: sh: rz-dmac: fix device leak on probe failure

In reply to Nobuhiro Iwamatsu

From: Johan Hovold <[email protected]>

commit 9fb490323997dcb6f749cd2660a17a39854600cd upstream.

Make sure to drop the reference taken when looking up the ICU device during probe also on probe failures (e.g. probe deferral).

Fixes 7de873201c44 ("dmaengine: sh: rz-dmac: Add RZ/V2H(P) support")
Cc Fabrizio Castro <[email protected]>
---
 drivers/dma/sh/rz-dmac.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
drivers/dma/sh/rz-dmac.c +11 -2
index 6f16d343a10968..da566fe13c3a6d 100644
@@ -863,6 +863,13 @@ static int rz_dmac_chan_probe(struct rz_dmac *dmac,
 	return ret;
 }
 
+static void rz_dmac_put_device(void *_dev)
+{
+	struct device *dev = _dev;
+
+	put_device(dev);
+}
+
 static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
 {
 	struct device_node *np = dev->of_node;
@@ -885,6 +892,10 @@ static int rz_dmac_parse_of_icu(struct device *dev, struct rz_dmac *dmac)
 		return -ENODEV;
 	}
 
+	ret = devm_add_action_or_reset(dev, rz_dmac_put_device, &dmac->icu.pdev->dev);
+	if (ret)
+		return ret;
+
 	dmac_index = args.args[0];
 	if (dmac_index > RZV2H_MAX_DMAC_INDEX) {
 		dev_err(dev, "DMAC index %u invalid.\n", dmac_index);
@@ -1047,8 +1058,6 @@ static int rz_dmac_remove(struct platform_device *pdev)
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
 
-	platform_device_put(dmac->icu.pdev);
-
 	return 0;
 }
 
Signature · 1 line
2.55.0
Reviewed-by on v1 2/5
#4 lore raw

Re: [cip-dev] [PATCH 6.1.y-cip 2/5] dmaengine: sh: rz-dmac: fix device leak on probe failure

Quoted 7 lines · Nobuhiro Iwamatsu via lists.cip-project.org

From: Johan Hovold<[email protected]>

commit 9fb490323997dcb6f749cd2660a17a39854600cd upstream.

Make sure to drop the reference taken when looking up the ICU device during probe also on probe failures (e.g. probe deferral).

Quoted 8 lines
Fixes 7de873201c44 ("dmaengine: sh: rz-dmac: Add RZ/V2H(P) support")
Cc:[email protected]	# 6.16
Cc: Fabrizio Castro<[email protected]>
Signed-off-by: Johan Hovold<[email protected]>
Reviewed-by: Fabrizio Castro<[email protected]>
Link:https://patch.msgid.link/[email protected]
Signed-off-by: Vinod Koul<[email protected]>
Signed-off-by: Nobuhiro Iwamatsu<[email protected]>
Reviewed-by on v1 2/5
#5 lore raw

Re: [cip-dev] [PATCH 6.1.y-cip 2/5] dmaengine: sh: rz-dmac: fix device leak on probe failure

In reply to Nobuhiro Iwamatsu

Hi!

Quoted 6 lines

From: Johan Hovold <[email protected]>

commit 9fb490323997dcb6f749cd2660a17a39854600cd upstream.

Make sure to drop the reference taken when looking up the ICU device during probe also on probe failures (e.g. probe deferral).

According to code, if "renesas,icu" is not present, that's still okay:

        ret = of_parse_phandle_with_fixed_args(np, "renesas,icu", 1, 0, &args);
        if (ret == -ENOENT)
		return 0;

but we skip put_device() in such case. Original code did do platform_device_put(NULL) in this case, so I guess we are still okay.

Best regards,
Pavel

#6 lore raw

PATCH 3/5 iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

In reply to Nobuhiro Iwamatsu

From: Claudiu Beznea <[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

---
 drivers/iio/adc/rzg2l_adc.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/iio/adc/rzg2l_adc.c +2 -2
index c19e3d29dbb861..e273785ba19d87 100644
@@ -446,6 +446,8 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (!indio_dev)
 		return -ENOMEM;
 
+	platform_set_drvdata(pdev, indio_dev);
+
 	adc = iio_priv(indio_dev);
 
 	adc->hw_params = device_get_match_data(dev);
@@ -500,8 +502,6 @@ static int rzg2l_adc_probe(struct platform_device *pdev)
 	if (ret)
 		return ret;
 
-	platform_set_drvdata(pdev, indio_dev);
-
 	ret = rzg2l_adc_hw_init(dev, adc);
 	if (ret)
 		return dev_err_probe(&pdev->dev, ret,
Signature · 1 line
2.55.0
Reviewed-by on v1 3/5
#7 lore raw

Re: [cip-dev] [PATCH 6.1.y-cip 3/5] iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Quoted 12 lines · Nobuhiro Iwamatsu via lists.cip-project.org

From: Claudiu Beznea<[email protected]>

commit c69e13965f26b8058f538ea8bdbd2d7718cf1fbe upstream.

When stress-testing the system by repeatedly unbinding and binding the ADC device in a loop, and the ADC is a supplier for another device (e.g., a thermal hardware block that reads temperature through the ADC), it may happen that the ADC device is runtime-resumed immediately after runtime PM is enabled, triggered by its consumer. At this point, since drvdata is not yet set and the driver's runtime PM callbacks rely on it, a crash can occur. To avoid this, set drvdata just after it was allocated.

Quoted 7 lines
#8 lore raw

PATCH 4/5 counter: rz-mtu3-cnt: prevent counter from being toggled multiple times

In reply to Nobuhiro Iwamatsu

From: Cosmin Tanislav <[email protected]>

commit 67c3f99bed6f422ba343d2b70a2eeeccdfd91bef upstream.

Runtime PM counter is incremented / decremented each time the sysfs enable file is written to.

If user writes 0 to the sysfs enable file multiple times, runtime PM usage count underflows, generating the following message.

rz-mtu3-counter rz-mtu3-counter.0: Runtime PM usage count underflow!

At the same time, hardware registers end up being accessed with clocks off in rz_mtu3_terminate_counter() to disable an already disabled channel.

If user writes 1 to the sysfs enable file multiple times, runtime PM usage count will be incremented each time, requiring the same number of 0 writes to get it back to 0.

If user writes 0 to the sysfs enable file while PWM is in progress, PWM is stopped without counter being the owner of the underlying MTU3 channel.

Check against the cached count_is_enabled value and exit if the user is trying to set the same enable value.

---
 drivers/counter/rz-mtu3-cnt.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/counter/rz-mtu3-cnt.c +8 -4
index d761e74d6aa309..c30e4a368cb657 100644
@@ -495,21 +495,25 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
 	struct rz_mtu3_cnt *const priv = counter_priv(counter);
 	int ret = 0;
 
+	mutex_lock(&priv->lock);
+
+	if (priv->count_is_enabled[count->id] == enable)
+		goto exit;
+
 	if (enable) {
-		mutex_lock(&priv->lock);
 		pm_runtime_get_sync(ch->dev);
 		ret = rz_mtu3_initialize_counter(counter, count->id);
 		if (ret == 0)
 			priv->count_is_enabled[count->id] = true;
-		mutex_unlock(&priv->lock);
 	} else {
-		mutex_lock(&priv->lock);
 		rz_mtu3_terminate_counter(counter, count->id);
 		priv->count_is_enabled[count->id] = false;
 		pm_runtime_put(ch->dev);
-		mutex_unlock(&priv->lock);
 	}
 
+exit:
+	mutex_unlock(&priv->lock);
+
 	return ret;
 }
 
Signature · 1 line
2.55.0
#9 lore raw

PATCH 5/5 counter: rz-mtu3-cnt: do not use struct rz_mtu3_channel's dev member

In reply to Nobuhiro Iwamatsu

From: Cosmin Tanislav <[email protected]>

commit 2932095c114b98cbb40ccf34fc00d613cb17cead upstream.

The counter driver can use HW channels 1 and 2, while the PWM driver can use HW channels 0, 1, 2, 3, 4, 6, 7.

The dev member is assigned both by the counter driver and the PWM driver for channels 1 and 2, to their own struct device instance, overwriting the previous value.

The sub-drivers race to assign their own struct device pointer to the same struct rz_mtu3_channel's dev member.

The dev member of struct rz_mtu3_channel is used by the counter sub-driver for runtime PM.

Depending on the probe order of the counter and PWM sub-drivers, the dev member may point to the wrong struct device instance, causing the counter sub-driver to do runtime PM actions on the wrong device.

To fix this, use the parent pointer of the counter, which is assigned during probe to the correct struct device, not the struct device pointer inside the shared struct rz_mtu3_channel.

---
 drivers/counter/rz-mtu3-cnt.c | 55 +++++++++++++++++------------------
 1 file changed, 27 insertions(+), 28 deletions(-)
drivers/counter/rz-mtu3-cnt.c +27 -28
index c30e4a368cb657..5c3d7f990291e2 100644
@@ -107,9 +107,9 @@ static bool rz_mtu3_is_counter_invalid(struct counter_device *counter, int id)
 	struct rz_mtu3_cnt *const priv = counter_priv(counter);
 	unsigned long tmdr;
 
-	pm_runtime_get_sync(priv->ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	tmdr = rz_mtu3_shared_reg_read(priv->ch, RZ_MTU3_TMDR3);
-	pm_runtime_put(priv->ch->dev);
+	pm_runtime_put(counter->parent);
 
 	if (id == RZ_MTU3_32_BIT_CH && test_bit(RZ_MTU3_TMDR3_LWA, &tmdr))
 		return false;
@@ -165,12 +165,12 @@ static int rz_mtu3_count_read(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	if (count->id == RZ_MTU3_32_BIT_CH)
 		*val = rz_mtu3_32bit_ch_read(ch, RZ_MTU3_TCNTLW);
 	else
 		*val = rz_mtu3_16bit_ch_read(ch, RZ_MTU3_TCNT);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
@@ -187,26 +187,26 @@ static int rz_mtu3_count_write(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	if (count->id == RZ_MTU3_32_BIT_CH)
 		rz_mtu3_32bit_ch_write(ch, RZ_MTU3_TCNTLW, val);
 	else
 		rz_mtu3_16bit_ch_write(ch, RZ_MTU3_TCNT, val);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
 }
 
 static int rz_mtu3_count_function_read_helper(struct rz_mtu3_channel *const ch,
-					      struct rz_mtu3_cnt *const priv,
+					      struct counter_device *const counter,
 					      enum counter_function *function)
 {
 	u8 timer_mode;
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	timer_mode = rz_mtu3_8bit_ch_read(ch, RZ_MTU3_TMDR1);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 
 	switch (timer_mode & RZ_MTU3_TMDR1_PH_CNT_MODE_MASK) {
 	case RZ_MTU3_TMDR1_PH_CNT_MODE_1:
@@ -240,7 +240,7 @@ static int rz_mtu3_count_function_read(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	ret = rz_mtu3_count_function_read_helper(ch, priv, function);
+	ret = rz_mtu3_count_function_read_helper(ch, counter, function);
 	mutex_unlock(&priv->lock);
 
 	return ret;
@@ -279,9 +279,9 @@ static int rz_mtu3_count_function_write(struct counter_device *counter,
 		return -EINVAL;
 	}
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	rz_mtu3_8bit_ch_write(ch, RZ_MTU3_TMDR1, timer_mode);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
@@ -300,9 +300,9 @@ static int rz_mtu3_count_direction_read(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	tsr = rz_mtu3_8bit_ch_read(ch, RZ_MTU3_TSR);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 
 	*direction = (tsr & RZ_MTU3_TSR_TCFD) ?
 		COUNTER_COUNT_DIRECTION_FORWARD : COUNTER_COUNT_DIRECTION_BACKWARD;
@@ -373,14 +373,14 @@ static int rz_mtu3_count_ceiling_write(struct counter_device *counter,
 		return -EINVAL;
 	}
 
-	pm_runtime_get_sync(ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	if (count->id == RZ_MTU3_32_BIT_CH)
 		rz_mtu3_32bit_ch_write(ch, RZ_MTU3_TGRALW, ceiling);
 	else
 		rz_mtu3_16bit_ch_write(ch, RZ_MTU3_TGRA, ceiling);
 
 	rz_mtu3_8bit_ch_write(ch, RZ_MTU3_TCR, RZ_MTU3_TCR_CCLR_TGRA);
-	pm_runtime_put(ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
@@ -491,7 +491,6 @@ static int rz_mtu3_count_enable_read(struct counter_device *counter,
 static int rz_mtu3_count_enable_write(struct counter_device *counter,
 				      struct counter_count *count, u8 enable)
 {
-	struct rz_mtu3_channel *const ch = rz_mtu3_get_ch(counter, count->id);
 	struct rz_mtu3_cnt *const priv = counter_priv(counter);
 	int ret = 0;
 
@@ -501,14 +500,14 @@ static int rz_mtu3_count_enable_write(struct counter_device *counter,
 		goto exit;
 
 	if (enable) {
-		pm_runtime_get_sync(ch->dev);
+		pm_runtime_get_sync(counter->parent);
 		ret = rz_mtu3_initialize_counter(counter, count->id);
 		if (ret == 0)
 			priv->count_is_enabled[count->id] = true;
 	} else {
 		rz_mtu3_terminate_counter(counter, count->id);
 		priv->count_is_enabled[count->id] = false;
-		pm_runtime_put(ch->dev);
+		pm_runtime_put(counter->parent);
 	}
 
 exit:
@@ -540,9 +539,9 @@ static int rz_mtu3_cascade_counts_enable_get(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(priv->ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	tmdr = rz_mtu3_shared_reg_read(priv->ch, RZ_MTU3_TMDR3);
-	pm_runtime_put(priv->ch->dev);
+	pm_runtime_put(counter->parent);
 	*cascade_enable = test_bit(RZ_MTU3_TMDR3_LWA, &tmdr);
 	mutex_unlock(&priv->lock);
 
@@ -559,10 +558,10 @@ static int rz_mtu3_cascade_counts_enable_set(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(priv->ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	rz_mtu3_shared_reg_update_bit(priv->ch, RZ_MTU3_TMDR3,
 				      RZ_MTU3_TMDR3_LWA, cascade_enable);
-	pm_runtime_put(priv->ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
@@ -579,9 +578,9 @@ static int rz_mtu3_ext_input_phase_clock_select_get(struct counter_device *count
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(priv->ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	tmdr = rz_mtu3_shared_reg_read(priv->ch, RZ_MTU3_TMDR3);
-	pm_runtime_put(priv->ch->dev);
+	pm_runtime_put(counter->parent);
 	*ext_input_phase_clock_select = test_bit(RZ_MTU3_TMDR3_PHCKSEL, &tmdr);
 	mutex_unlock(&priv->lock);
 
@@ -598,11 +597,11 @@ static int rz_mtu3_ext_input_phase_clock_select_set(struct counter_device *count
 	if (ret)
 		return ret;
 
-	pm_runtime_get_sync(priv->ch->dev);
+	pm_runtime_get_sync(counter->parent);
 	rz_mtu3_shared_reg_update_bit(priv->ch, RZ_MTU3_TMDR3,
 				      RZ_MTU3_TMDR3_PHCKSEL,
 				      ext_input_phase_clock_select);
-	pm_runtime_put(priv->ch->dev);
+	pm_runtime_put(counter->parent);
 	mutex_unlock(&priv->lock);
 
 	return 0;
@@ -640,7 +639,7 @@ static int rz_mtu3_action_read(struct counter_device *counter,
 	if (ret)
 		return ret;
 
-	ret = rz_mtu3_count_function_read_helper(ch, priv, &function);
+	ret = rz_mtu3_count_function_read_helper(ch, counter, &function);
 	if (ret) {
 		mutex_unlock(&priv->lock);
 		return ret;
Signature · 1 line
2.55.0
Reviewed-by on the v1 series
#10 lore raw
In reply to Nobuhiro Iwamatsu

Hi!

Quoted 3 lines

This is a patch series that fixes CVEs related to patches backported to CIP kernel.
The following CVEs and commits are addressed in this:

This looks okay to me.

I can apply the series if it passes testing and there are no other comments (but it may be easier for you to apply it...?).

Best regards,
Pavel

Applied
#11 lore raw
In reply to Nobuhiro Iwamatsu

Hi!

Quoted 8 lines

Claudiu Beznea (1):
iio: adc: rzg2l_adc: Set driver data before enabling runtime PM

Cosmin Tanislav (2):
counter: rz-mtu3-cnt: prevent counter from being toggled multiple
times
counter: rz-mtu3-cnt: do not use struct rz_mtu3_channel's dev member

Quoted 5 lines

Felix Gu (1):
i3c: master: renesas: Fix memory leak in renesas_i3c_i3c_xfers()

Johan Hovold (1):
dmaengine: sh: rz-dmac: fix device leak on probe failure

Thank you, applied.

Best regards,
Pavel