Re: [PATCH] net: ethernet: broadcom: sb1250-mac: Add checks for kcalloc() in sbdma_initctx()

From: Jakub Kicinski

Date: Thu Sep 18 2025 - 10:15:17 EST


On Thu, 18 Sep 2025 20:10:51 +0800 Guangshuo Li wrote:
> Fixes: 73d739698017 ("sb1250-mac.c: De-typedef, de-volatile, de-etc...")
> Fixes: c477f3348abb ("drivers/net/sb1250-mac.c: kmalloc + memset conversion to kcalloc")

neither of these tags is correct, the bug existed before them
The Fixes tag should point to the commit that added the bug,
not the last commit that touched the line

> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Guangshuo Li <lgs201920130244@xxxxxxxxx>
> ---
> drivers/net/ethernet/broadcom/sb1250-mac.c | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/broadcom/sb1250-mac.c b/drivers/net/ethernet/broadcom/sb1250-mac.c
> index 30865fe03eeb..e16a49e22488 100644
> --- a/drivers/net/ethernet/broadcom/sb1250-mac.c
> +++ b/drivers/net/ethernet/broadcom/sb1250-mac.c
> @@ -625,6 +625,8 @@ static void sbdma_initctx(struct sbmacdma *d, struct sbmac_softc *s, int chan,
> d->sbdma_dscrtable_unaligned = kcalloc(d->sbdma_maxdescr + 1,
> sizeof(*d->sbdma_dscrtable),
> GFP_KERNEL);
> + if (!d->sbdma_dscrtable_unaligned)
> + return; /* avoid NULL deref in ALIGN/phys conversion */

This comment is completely unnecessary

Please make sure to read:
https://www.kernel.org/doc/html/next/process/maintainer-netdev.html
before proceeding
--
pw-bot: cr