From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C061837BE7D; Mon, 9 Feb 2026 14:43:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648237; cv=none; b=ZkzusfsssrPoe1kiJwHF3Webh75L9ybf9pn5Wfvah3JiTIc2qfpMOX4CUh1p020Eg4sUoVzu/wQ0kuQbB0XnUdCqw7P+F7pCXpjeMRc9ZDtKq656sRcW4NPaFMYqTUbC3beIyR9a2MubuVfg53chCgiQQAxzQRKpKmr3RrcRL4w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770648237; c=relaxed/simple; bh=L+ZECYuHh/gy5YLGqD6X53HdZy0z4buARw729ejNLtY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ajrtf10JOqKdc1GWzluH6EghqgMxb214vL9BJrSrClY2KGeOlrwo7K8E0yj2TvfgP6V/lYEeiRLlnFFqj6Aetkt2N7UIYVhREXlUtR+9zd3YmhUbD8uz9Ep+T9iBvU9gA3TAnLRsN+WXurzTXLWHFjs6DURNvDYI6jOThW0AymA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zVOlPbp9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="zVOlPbp9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AED4C116C6; Mon, 9 Feb 2026 14:43:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1770648237; bh=L+ZECYuHh/gy5YLGqD6X53HdZy0z4buARw729ejNLtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zVOlPbp97nXl2vJoDTJDc7rPDUq/j0zalXm3kVzzQfT33DHCA0d3pm3fr/S4+7AGp 0ytyMA7TptvQN5Kk7S7+k+BlhOqD4/zRcpmxZuRsMB/hDH+HBEH10fmSqEirGYkCRB 4h/QivBfDO/W5VVvukSzxtdnYm25VPIMZ/ZJaKsM= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Yuhao Jiang , Junrui Luo , Andrew Lunn , Jakub Kicinski , Sasha Levin Subject: [PATCH 6.1 48/69] dpaa2-switch: prevent ZERO_SIZE_PTR dereference when num_ifs is zero Date: Mon, 9 Feb 2026 15:24:16 +0100 Message-ID: <20260209142303.652442275@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260209142301.913348974@linuxfoundation.org> References: <20260209142301.913348974@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Junrui Luo [ Upstream commit ed48a84a72fefb20a82dd90a7caa7807e90c6f66 ] 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 Reported-by: Junrui Luo Fixes: 0b1b71370458 ("staging: dpaa2-switch: handle Rx path on control interface") Signed-off-by: Junrui Luo Reviewed-by: Andrew Lunn Link: https://patch.msgid.link/SYBPR01MB7881BEABA8DA896947962470AF91A@SYBPR01MB7881.ausprd01.prod.outlook.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index e928fea16e841..801956c048752 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -2970,6 +2970,12 @@ static int dpaa2_switch_init(struct fsl_mc_device *sw_dev) goto err_close; } + if (!ethsw->sw_attr.num_ifs) { + dev_err(dev, "DPSW device has no interfaces\n"); + err = -ENODEV; + goto err_close; + } + err = dpsw_get_api_version(ethsw->mc_io, 0, ðsw->major, ðsw->minor); -- 2.51.0