From: <shao.mingyin@zte.com.cn>
To: <lee@kernel.org>, <mfd@lists.linux.dev>
Cc: <tony@atomide.com>, <linux-omap@vger.kernel.org>,
<tharvey@gateworks.com>, <support.opensource@diasemi.com>,
<patches@opensource.cirrus.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH RESEND 2/5] mfd: twl6030-irq: Don't write garbage to interrupt mask on read failure
Date: Sat, 7 Nov 2026 16:21:21 +0800 (CST) [thread overview]
Message-ID: <20261107162121178QffEnlezkInAnSMsrwQzA@zte.com.cn> (raw)
In-Reply-To: <202611071621143491uRwluLhxYsUHx2V3qhm_@zte.com.cn>
From: Shao Mingyin <shao.mingyin@zte.com.cn>
twl6030_interrupt_unmask() and twl6030_interrupt_mask() ignore the return
value of the twl_i2c_read_u8() that fetches the current mask value. When
the read fails, "unmask_value"/"mask_value" hold uninitialized stack data
which is then masked/unmasked and written back to the INT_MSK_A/B/C
registers, corrupting the interrupt mask configuration of the whole PMIC.
Bail out with the read error before touching the value or writing it back.
Fixes: e8deb28ca8e2 ("mfd: Add support for twl6030 irq framework")
Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
---
---
Resend: the first copy of this patch lost its final empty context
line in transit; the diff below is unchanged.
diff --git a/drivers/mfd/twl6030-irq.c b/drivers/mfd/twl6030-irq.c
index 0ca00f618d4d..1333c4e9cdd7 100644
--- a/drivers/mfd/twl6030-irq.c
+++ b/drivers/mfd/twl6030-irq.c
@@ -235,10 +235,11 @@ int twl6030_interrupt_unmask(u8 bit_mask, u8 offset)
ret = twl_i2c_read_u8(TWL_MODULE_PIH, &unmask_value,
REG_INT_STS_A + offset);
+ if (ret)
+ return ret;
unmask_value &= (~(bit_mask));
- ret |= twl_i2c_write_u8(TWL_MODULE_PIH, unmask_value,
+ return twl_i2c_write_u8(TWL_MODULE_PIH, unmask_value,
REG_INT_STS_A + offset); /* unmask INT_MSK_A/B/C */
- return ret;
}
EXPORT_SYMBOL(twl6030_interrupt_unmask);
@@ -249,10 +250,11 @@ int twl6030_interrupt_mask(u8 bit_mask, u8 offset)
ret = twl_i2c_read_u8(TWL_MODULE_PIH, &mask_value,
REG_INT_STS_A + offset);
+ if (ret)
+ return ret;
mask_value |= (bit_mask);
- ret |= twl_i2c_write_u8(TWL_MODULE_PIH, mask_value,
+ return twl_i2c_write_u8(TWL_MODULE_PIH, mask_value,
REG_INT_STS_A + offset); /* mask INT_MSK_A/B/C */
- return ret;
}
EXPORT_SYMBOL(twl6030_interrupt_mask);
--
2.47.0
--
2.47.0
next prev parent reply other threads:[~2026-11-07 8:21 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 8:21 [PATCH RESEND 0/5] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
2026-11-07 8:21 ` [PATCH RESEND 1/5] mfd: tps65219: Fix out-of-bounds access in tps65214 IRQ map shao.mingyin
2026-11-07 8:21 ` shao.mingyin [this message]
2026-11-07 8:21 ` [PATCH RESEND 3/5] mfd: arizona: Free info IRQs on probe failure shao.mingyin
2026-11-07 8:21 ` [PATCH RESEND 4/5] mfd: da9052: Disable IRQ wake on device removal shao.mingyin
2026-11-07 8:21 ` [PATCH RESEND 5/5] mfd: gateworks-gsc: Check firmware CRC reads for errors shao.mingyin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261107162121178QffEnlezkInAnSMsrwQzA@zte.com.cn \
--to=shao.mingyin@zte.com.cn \
--cc=lee@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=mfd@lists.linux.dev \
--cc=patches@opensource.cirrus.com \
--cc=support.opensource@diasemi.com \
--cc=tharvey@gateworks.com \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®