Re: [PATCH] mailbox: riscv-sbi-mpxy: Fix inverted notification loop

Anup Patel <[email protected]>
Newsgroups org.infradead.lists.linux-riscv,org.kernel.vger.linux-kernel
Message-ID <CAAhSdy2J9_6k2V=o+oPaHfUqWqjMwQ-bVrZhFfzzB1Y0=PN50g@mail.gmail.com>
On Sat, Aug 22, 2026 at 10:14 PM liutong <[email protected]> wrote:
>
> In mpxy_mbox_peek_rpmi_data(), the while loop condition checks:
>
>   (events_data_len - pos) <= sizeof(*event)
>
> This is inverted. The loop should continue while there is enough
> remaining data to hold at least one event header, i.e. >=. With <=
> the loop body is entered only when the remaining data is smaller than
> one header, which is never useful. In practice, since events_data_len
> is always larger than sizeof(*event) (4 bytes), the condition is false
> on the first iteration and the loop is never entered.
>
> All RPMI notification events are silently dropped.
>
> Fix the condition from <= to >=.
>
> Fixes: bf3022a4eb11 ("mailbox: Add RISC-V SBI message proxy (MPXY) based mailbox driver")
> Signed-off-by: liutong <[email protected]>

LGTM.

Reviewed-by: Anup Patel <[email protected]>

Thanks,
Anup

> ---
>  drivers/mailbox/riscv-sbi-mpxy-mbox.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/mailbox/riscv-sbi-mpxy-mbox.c b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
> index 7c9c006b7..18da9efcc 100644
> --- a/drivers/mailbox/riscv-sbi-mpxy-mbox.c
> +++ b/drivers/mailbox/riscv-sbi-mpxy-mbox.c
> @@ -480,7 +480,7 @@ static void mpxy_mbox_peek_rpmi_data(struct mbox_chan *chan,
>         struct rpmi_mbox_message msg;
>         unsigned long pos = 0;
>
> -       while (pos < events_data_len && (events_data_len - pos) <= sizeof(*event)) {
> +       while (pos < events_data_len && (events_data_len - pos) >= sizeof(*event)) {
>                 event = (struct rpmi_notification_event *)(notif->events_data + pos);
>
>                 msg.type = RPMI_MBOX_MSG_TYPE_NOTIFICATION_EVENT;
> --
> 2.34.1
>

_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.