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 D1B72313E1C; Mon, 13 Oct 2025 15:41:29 +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=1760370089; cv=none; b=F91MWnQ3QUXIPH/WwegBw8nKYCKAH4MyILc+M3pDUiXOe4eb+aO8zX6WoznHsCNZh6G1HkgFq+NqLRLg1MLL+7zrsmS2ylvrS8z+JMB9X2te/4QnF57tsRf4D7Uht457gw3PiPdu32sNL9vaw44Apbo5QozOQvBZtH1S+WvNqLQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760370089; c=relaxed/simple; bh=4004CS0Db0KFory9r+ab5/RCsETVJv02mpjzZM/CPSI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LqYM+3SV+MQYMNYkLrc3r3xLzc7NESvgScptQ07afZ07GE8YqxN0R5z4dp4ApPE+GqifTM3wBgrShAR2in4F3pbYrXKmneKUWEzXVIzmH23BNqZzA8B0C1sIVeTEjSDrQzgX+9pewJWJ/Oon/+ausYaMxZQZoJcT69+iN3gkvJU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=F7QN7elj; 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="F7QN7elj" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0B25CC4CEE7; Mon, 13 Oct 2025 15:41:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1760370089; bh=4004CS0Db0KFory9r+ab5/RCsETVJv02mpjzZM/CPSI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=F7QN7eljl9iLsSlNKoSxkoXWsI3LdWRWm2GHOoZmJ9qHReWx2d8YMTSLBFX3QV9iV J/Rr//pRztL8WUvhCV3uoaTpCJwkKfTg5NbB2ttf5CWFSL+z270wwIsMuJ0buo6GB4 pNwj8bvY2AOpMAvmUX3u3yI6HwxA5Vc2mmmbK/wQ= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jakub Kicinski , Yeounsu Moon , Andrew Lunn , Sasha Levin Subject: [PATCH 6.17 474/563] net: dlink: handle copy_thresh allocation failure Date: Mon, 13 Oct 2025 16:45:35 +0200 Message-ID: <20251013144428.460505436@linuxfoundation.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251013144411.274874080@linuxfoundation.org> References: <20251013144411.274874080@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.17-stable review patch. If anyone has any objections, please let me know. ------------------ From: Yeounsu Moon [ Upstream commit 8169a6011c5fecc6cb1c3654c541c567d3318de8 ] The driver did not handle failure of `netdev_alloc_skb_ip_align()`. If the allocation failed, dereferencing `skb->protocol` could lead to a NULL pointer dereference. This patch tries to allocate `skb`. If the allocation fails, it falls back to the normal path. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Suggested-by: Jakub Kicinski Tested-on: D-Link DGE-550T Rev-A3 Signed-off-by: Yeounsu Moon Reviewed-by: Andrew Lunn Link: https://patch.msgid.link/20250928190124.1156-1-yyyynoom@gmail.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/ethernet/dlink/dl2k.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/dlink/dl2k.c b/drivers/net/ethernet/dlink/dl2k.c index 6bbf6e5584e54..1996d2e4e3e2c 100644 --- a/drivers/net/ethernet/dlink/dl2k.c +++ b/drivers/net/ethernet/dlink/dl2k.c @@ -964,15 +964,18 @@ receive_packet (struct net_device *dev) } else { struct sk_buff *skb; + skb = NULL; /* Small skbuffs for short packets */ - if (pkt_len > copy_thresh) { + if (pkt_len <= copy_thresh) + skb = netdev_alloc_skb_ip_align(dev, pkt_len); + if (!skb) { dma_unmap_single(&np->pdev->dev, desc_to_dma(desc), np->rx_buf_sz, DMA_FROM_DEVICE); skb_put (skb = np->rx_skbuff[entry], pkt_len); np->rx_skbuff[entry] = NULL; - } else if ((skb = netdev_alloc_skb_ip_align(dev, pkt_len))) { + } else { dma_sync_single_for_cpu(&np->pdev->dev, desc_to_dma(desc), np->rx_buf_sz, -- 2.51.0