mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Lee Jones <lee@kernel.org>
To: shao.mingyin@zte.com.cn
Cc: mfd@lists.linux.dev, 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: Re: [PATCH 1/5] mfd: tps65219: Fix out-of-bounds access in tps65214 IRQ map
Date: Wed, 18 Nov 2026 17:46:56 +0000	[thread overview]
Message-ID: <20261118174656.GF98456@joneslee-macbookpro.roam.internal> (raw)
In-Reply-To: <20261107160743097R9VvfD_5S5vK286ZLzPhG@zte.com.cn>

On Sat, 07 Nov 2026, shao.mingyin@zte.com.cn wrote:

> From: Shao Mingyin <shao.mingyin@zte.com.cn>
> 
> The tps65214_sub_irq_offsets[] array has only seven entries (bits 0-5
> and 7; INT_SOURCE bit 6 is reserved) while the corresponding IRQ chip
> advertises num_main_status_bits = 8.  regmap-irq's read_irq_data()
> indexes sub_reg_offsets with the main-status bit number, so whenever
> bit 7 of INT_SOURCE is set (the power-button interrupt) it reads past
> the end of the seven-element array and uses garbage offset/num_regs
> values to compute status_buf indices, which can also lead to an
> out-of-bounds status_buf access.
> 
> Add an empty placeholder entry for the reserved bit 6 so that the array
> lines up with the bit numbering and bit 7 hits the power-button entry.
> 
> Fixes: 7947219ab1a2 ("mfd: tps65219: Add support for TI TPS65214 PMIC")
> Signed-off-by: Shao Mingyin <shao.mingyin@zte.com.cn>
> ---
> diff --git a/drivers/mfd/tps65219.c b/drivers/mfd/tps65219.c
> index f8c08dd86618..4f4bfc49542c 100644
> --- a/drivers/mfd/tps65219.c
> +++ b/drivers/mfd/tps65219.c
> @@ -268,6 +268,7 @@ static const struct regmap_irq_sub_irq_map tps65214_sub_irq_offsets[] = {
>  	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit3_offsets),
>  	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit4_offsets),
>  	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit5_offsets),
> +	{ .num_regs = 0 },	/* INT_SOURCE bit 6 is reserved */
>  	REGMAP_IRQ_MAIN_REG_OFFSET(tps65214_bit7_offsets),

This is fragile and `num_regs` is already zero, so it's also pointless.

A better solution would be to specify each element.

Why not use REGMAP_IRQ_REG(), which lets you do this?

Or, add a new, cleaner one:

  #define REGMAP_IRQ_MAIN_BIT_OFFSET(bit, arr)        \
  	[bit] = REGMAP_IRQ_MAIN_REG_OFFSET(arr)


-- 
Lee Jones

  reply	other threads:[~2026-11-18 17:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-07  8:07 [PATCH 0/5] mfd: Fix an out-of-bounds IRQ map and error-path bugs shao.mingyin
2026-11-07  8:07 ` [PATCH 1/5] mfd: tps65219: Fix out-of-bounds access in tps65214 IRQ map shao.mingyin
2026-11-18 17:46   ` Lee Jones [this message]
2026-11-07  8:07 ` [PATCH 2/5] mfd: twl6030-irq: Don't write garbage to interrupt mask on read failure shao.mingyin
2026-11-07  8:07 ` [PATCH 3/5] mfd: arizona: Free info IRQs on probe failure shao.mingyin
2026-11-18 17:50   ` Lee Jones
2026-11-07  8:07 ` [PATCH 4/5] mfd: da9052: Disable IRQ wake on device removal shao.mingyin
2026-11-18 17:57   ` Lee Jones
2026-11-07  8:07 ` [PATCH 5/5] mfd: gateworks-gsc: Check firmware CRC reads for errors shao.mingyin
2026-11-18 18:22   ` Lee Jones

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=20261118174656.GF98456@joneslee-macbookpro.roam.internal \
    --to=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=shao.mingyin@zte.com.cn \
    --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®