From: John Paul Adrian Glaubitz <glaubitz@physik.fu-berlin.de>
To: Geert Uytterhoeven <geert@linux-m68k.org>,
Karl Mehltretter <kmehltretter@gmail.com>
Cc: Yoshinori Sato <yoshinori.sato@nifty.com>,
Rich Felker <dalias@libc.org>,
linux-sh@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sh: intc: sort the prio and sense lists after filling them
Date: Wed, 14 Oct 2026 10:00:35 +0200 [thread overview]
Message-ID: <3b5171841776d58f0d19fbe585b356e2a7f7480e.camel@physik.fu-berlin.de> (raw)
In-Reply-To: <CAMuHMdXfpChkH-Ad5x7p579+4rBQtfF5CKwwRrdZ6CxDPDWMCg@mail.gmail.com>
Hi Geert,
On Wed, 2026-10-14 at 09:03 +0200, Geert Uytterhoeven wrote:
> Hi Karl,
>
> On Sun, 27 Sept 2026 at 21:14, Karl Mehltretter <kmehltretter@gmail.com> wrote:
> > register_intc_controller() sorts d->prio and d->sense right after
> > allocating them, with hw->nr_prio_regs and hw->nr_sense_regs as the
> > element count. The lists hold hw->nr_vectors entries and are only
> > filled later, by intc_register_irq().
> >
> > On SH7785, sh7785-irq0123 and sh7785-irq4567 have four vectors but the
> > SoC's eleven priority registers, so sort() swaps 88 bytes in a 32 byte
> > kmalloc object at boot. slub_debug=FZPU reports "Right Redzone
> > overwritten" in kmalloc-32, and v6.5 and v6.6 panic in
> > __kmem_cache_alloc_node() while registering sh7785-irq0123.
> >
> > Found with a custom QEMU model of the SH7785LCR. On it, v6.4
> > sh7785lcr_defconfig boots with SLAB, the defconfig default before v6.5,
> > and hangs before the console is up when built with SLUB.
> >
> > Sort the lists once all vectors are registered, with the number of
> > entries that were added.
> >
> > Fixes: b59f9f9775e6 ("sh: intc: optimize intc IRQ lookup")
> > Cc: stable@vger.kernel.org
> > Assisted-by: LLM
> > Signed-off-by: Karl Mehltretter <kmehltretter@gmail.com>
>
> Thanks for your patch!
>
> > --- a/drivers/sh/intc/core.c
> > +++ b/drivers/sh/intc/core.c
> > @@ -275,9 +275,6 @@ int __init register_intc_controller(struct intc_desc *desc)
> > k += save_reg(d, k, hw->prio_regs[i].set_reg, smp);
> > k += save_reg(d, k, hw->prio_regs[i].clr_reg, smp);
> > }
> > -
> > - sort(d->prio, hw->nr_prio_regs, sizeof(*d->prio),
> > - intc_handle_int_cmp, NULL);
>
> Yeah, if hw->nr_prio_regs > hw->nr_vectors, this overflows d->prio[].
> Furthermore, this sorting is useless, as d->prio[] is still empty
> (all zeroes).
>
> > }
> >
> > if (hw->sense_regs) {
> > @@ -287,9 +284,6 @@ int __init register_intc_controller(struct intc_desc *desc)
> >
> > for (i = 0; i < hw->nr_sense_regs; i++)
> > k += save_reg(d, k, hw->sense_regs[i].reg, 0);
> > -
> > - sort(d->sense, hw->nr_sense_regs, sizeof(*d->sense),
> > - intc_handle_int_cmp, NULL);
>
> Similar.
>
> > }
> >
> > if (hw->subgroups)
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Thanks for the additional review. I have already merged this patch in my
tree, but I will add your Reviewed-by with some git foo.
Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
prev parent reply other threads:[~2026-10-14 8:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-27 19:13 Karl Mehltretter
2026-09-27 19:30 ` Karl Mehltretter
2026-09-28 15:01 ` John Paul Adrian Glaubitz
2026-09-28 16:03 ` Geert Uytterhoeven
2026-09-28 16:46 ` John Paul Adrian Glaubitz
2026-09-28 17:00 ` Geert Uytterhoeven
2026-09-28 17:21 ` John Paul Adrian Glaubitz
2026-09-28 18:34 ` Geert Uytterhoeven
2026-09-28 19:02 ` John Paul Adrian Glaubitz
2026-09-28 21:22 ` Karl Mehltretter
2026-09-28 21:29 ` John Paul Adrian Glaubitz
2026-09-29 9:20 ` John Paul Adrian Glaubitz
2026-09-29 9:39 ` John Paul Adrian Glaubitz
2026-10-02 4:57 ` John Paul Adrian Glaubitz
2026-10-02 21:58 ` Karl Mehltretter
2026-10-03 6:53 ` John Paul Adrian Glaubitz
2026-10-03 7:51 ` John Paul Adrian Glaubitz
2026-10-13 16:47 ` John Paul Adrian Glaubitz
2026-10-13 17:24 ` John Paul Adrian Glaubitz
2026-10-14 7:03 ` Geert Uytterhoeven
2026-10-14 8:00 ` John Paul Adrian Glaubitz [this message]
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=3b5171841776d58f0d19fbe585b356e2a7f7480e.camel@physik.fu-berlin.de \
--to=glaubitz@physik.fu-berlin.de \
--cc=dalias@libc.org \
--cc=geert@linux-m68k.org \
--cc=kmehltretter@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sh@vger.kernel.org \
--cc=yoshinori.sato@nifty.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®