[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <8241c7f7-6de4-4621-ad80-3f1af000afdd@lunn.ch>
Date: Wed, 28 Jan 2026 14:48:26 +0100
From: Andrew Lunn <andrew@...n.ch>
To: Junrui Luo <moonafterrain@...look.com>
Cc: Ioana Ciornei <ioana.ciornei@....com>,
Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Yuhao Jiang <danisjiang@...il.com>
Subject: Re: [PATCH] dpaa2-switch: prevent ZERO_SIZE_PTR dereference when
num_ifs is zero
On Wed, Jan 28, 2026 at 04:07:34PM +0800, Junrui Luo wrote:
> The driver allocates arrays for ports, FDBs, and filter blocks using
> kcalloc() with ethsw->sw_attr.num_ifs as the element count. When the
> device reports zero interfaces (either due to hardware configuration
> or firmware issues), kcalloc(0, ...) returns ZERO_SIZE_PTR (0x10)
> instead of NULL.
>
> Later in dpaa2_switch_probe(), the NAPI initialization unconditionally
> accesses ethsw->ports[0]->netdev, which attempts to dereference
> ZERO_SIZE_PTR (address 0x10), resulting in a kernel panic.
>
> Add a check to ensure num_ifs is greater than zero after retrieving
> device attributes. This prevents the zero-sized allocations and
> subsequent invalid pointer dereference.
>
> Reported-by: Yuhao Jiang <danisjiang@...il.com>
> Reported-by: Junrui Luo <moonafterrain@...look.com>
> Fixes: 0b1b71370458 ("staging: dpaa2-switch: handle Rx path on control interface")
> Signed-off-by: Junrui Luo <moonafterrain@...look.com>
The patch itself looks O.K. However, we ask that fixes are based on
net, and indicate this in the subject line.
https://www.kernel.org/doc/html/latest/process/maintainer-netdev.html
Reviewed-by: Andrew Lunn <andrew@...n.ch>
Andrew
Powered by blists - more mailing lists