Re: [PATCH] MIPS: Remove unnecessary zero-length struct member

From: Maciej W. Rozycki
Date: Thu Apr 17 2025 - 04:10:43 EST


On Thu, 17 Apr 2025, Thorsten Blum wrote:

> > Also this is broken anyway: if you use MAX_REG_OFFSET for `offset' passed
> > to `regs_get_register', then data past the end of `regs' will be accessed.
>
> Yes, true. It seems like
>
> if (unlikely(offset >= MAX_REG_OFFSET))
> return 0;
>
> should do the trick.

No, other platforms use the same (offset > MAX_REG_OFFSET) check that we
do and just set MAX_REG_OFFSET correctly to point at the last register in
`struct pt_regs'.

> The comment also says "If @offset is bigger than MAX_REG_OFFSET", rather
> than "is bigger than or equal to".

And quite correctly so.

> Happy to add it to v2 or a separate patch, if this is actually correct?!

Yes, please send v2. There's no point in changing MAX_REG_OFFSET twice.

Maciej