From nobody Mon Jun 15 10:44:30 2026 Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7B77230E834 for ; Thu, 9 Apr 2026 18:40:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775760034; cv=none; b=XI80/hOTzNNzY4oyM5br6IJ8XQzac8IBvlghzasvWWZlElk/2I/NGJMyOH8uOhs2h+qHD6Qq0lv0jL6KJHXgZMhROVLIN1ex3yonOgwt0g8xTe5JNFgZkZhWP6QQn6UTbcyxoQCG5RD9Rj9Pv/3M2MFWtDwXp6aA0Cw3l/J0P08= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775760034; c=relaxed/simple; bh=QS69EOwbeilaE+gg/PyPbGlFPcxKmaTs+d+KkM8Dpr8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SbaWH1J3zOLAj7fOOTaPCHf4BTzHRptP4V7ZTA8Cs9p3mLSU+RhZHcfGUwCEIKYkO6z6ntLuzHjY3xii+ZUE2lj7RBQKAEfvElqleo5YrjnWU4Hiz/nHl+Alb5lHZ6UO4YQc/gqXK1L9x+kTiSj8rYBX3wbZIGbm/JPXgArYNVU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=XvdCLdj/; arc=none smtp.client-ip=209.85.221.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XvdCLdj/" Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-43cfb723698so871022f8f.3 for ; Thu, 09 Apr 2026 11:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775760032; x=1776364832; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/oP20LkfN1ljFvhP3IKO8BTW+iHHIGJpKL/nZSlyxTA=; b=XvdCLdj/P+hdkNLwEc2YeM15ZIknZCcXZbd5As3Nno5y1SolDjb7RhRZcpfTehudL3 LGFlanQvcoWcclICGcXJIVfVccGuJ3hKAY3EmjYYEz+P8qut7bMKood1hgHUiLQ33YX0 7oTYIGeUpQrZ8aV8aZPCux2oSw4M25kZvxb+kzrywwd9QilYJZmWsXr1RRc4fiohqVg7 5aDaG1Hw83RHDoKUQbqHHrmO080eR2TdYUryn4QpEzAWBkTtjs2cTGeDl3+I3H9qGd0U foedFIDfMNXepV76n5SobqRiPE9paET60SGMmLn/JkIJ70UkJlIThCNocqnFETZFqv8l KRtQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775760032; x=1776364832; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=/oP20LkfN1ljFvhP3IKO8BTW+iHHIGJpKL/nZSlyxTA=; b=GA0Y6MRCOrv66tjOavP8hYrrMZYY8wuJtcSlEfdyS/nzcnoNL2iZuuUOxe21ebZHQv Xq6tQqhkAk/+QOCJQbGct+/nUaKSVc2sfIlxGVRuoA5xRgNK5/hgzpFWDy+ZYmg63UHG TbN70rDPG1p5TOt4L14fkMBIeFIM2qpBcqxoNddcEVhLiMt5+JbIEh2Tl/Se026N/hK2 RM7rULNeuEmvMXYV1xFgEqX2Mn8zE2xNtXrEW9rK7Uud1m/ZBM8Znt5vI9L6TjUs6dgi WM9Mo7k1zNBo4QX7hrP3krnBsk9pu2/uUemLKDr5EyEw7ftu10EJ9D3XNj71V4Y8l6ev ivHQ== X-Forwarded-Encrypted: i=1; AJvYcCWGtzcMTUqdca2rY+r1UwGYeHof9VKxFsUUHssZpNOMvMmuaywWpLxDKnF3qFT625sD0wPrqZH6M7c0kcQ=@vger.kernel.org X-Gm-Message-State: AOJu0YwxFDzWfArq12KXdPOvM6Wz3yqB4c6am4Lcm3XvcMfE4ARYt3Sy tukBG5rm3wauHPkoRtuShK7nO6QZAWDQ0tDeipjtQ0sYW2rKE3f/qgUV X-Gm-Gg: AeBDievOqqyHL/hkvAqF2fksnNLdVz03B4GSmqzNYqT53t9PkhpPo5ZtHG7wP7GkXlz bTjrkeqmX3d/vcPhOpXPfjCrcP5rUdW8vwQdl2fKhdPAfhImUTYPjsv95YG01tKkB1cOgo3y/HU cRCou5DmwMvMqKEKidw0xTqvqEQgKSFZHfnK/S8Zw+Dp1vabTJlL6MQsuGlviYsuYMqmVYMOgFA G/TPzNfIm0sMy3wTGg6ivHW5RwlfM4L00cBH34JX+cKiI5/LLFyQNcMzsyfuGtL/Q3kdEEgGNEl SfvEuU2g/XLEn4ZR9KdWqbN6GLEgibHo+hnxEO+3xBFQBUoAmYNOES0xir5f6A4jwC4MDIgWZYW v0dyVfPBhnvU62VhVuwBEmJy7+4NQrNC+g9ZfHN8bisS6R0JhJP4vvZfnfjCTCgUYfC8WfMzU1M 1Mb1nPDQ0g5Jjlv5YhBIe9MRjuEHf31gyengUdKOrhZOdKk60+mdSYKoivO4v6UeSWiRBpDUhGr BgLHlSeCo4z X-Received: by 2002:a05:6000:4007:b0:43c:fbde:3101 with SMTP id ffacd0b85a97d-43d642e7cc5mr237497f8f.41.1775760031718; Thu, 09 Apr 2026 11:40:31 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d63e5d88bsm560563f8f.37.2026.04.09.11.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 11:40:31 -0700 (PDT) From: David Carlier To: netdev@vger.kernel.org Cc: vburru@marvell.com, sedara@marvell.com, srasheed@marvell.com, sburla@marvell.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, David Carlier Subject: [PATCH net v2 1/2] octeon_ep_vf: introduce octep_vf_oq_next_idx() helper Date: Thu, 9 Apr 2026 19:40:08 +0100 Message-ID: <20260409184009.930359-2-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260409184009.930359-1-devnexen@gmail.com> References: <20260409184009.930359-1-devnexen@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Introduce octep_vf_oq_next_idx() to consolidate the repeated ring index advance and wraparound pattern in __octep_vf_oq_process_rx(). No functional change intended. Signed-off-by: David Carlier --- .../ethernet/marvell/octeon_ep_vf/octep_vf_rx.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c b/driv= ers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c index b579d5b545c4..7bd1b9b8d7f5 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c @@ -352,6 +352,11 @@ static int octep_vf_oq_check_hw_for_pkts(struct octep_= vf_device *oct, return new_pkts; } =20 +static inline u32 octep_vf_oq_next_idx(struct octep_vf_oq *oq, u32 idx) +{ + return (idx + 1 =3D=3D oq->max_count) ? 0 : idx + 1; +} + /** * __octep_vf_oq_process_rx() - Process hardware Rx queue and push to stac= k. * @@ -415,10 +420,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_de= vice *oct, skb =3D napi_build_skb((void *)resp_hw, PAGE_SIZE); skb_reserve(skb, data_offset); skb_put(skb, buff_info->len); - read_idx++; desc_used++; - if (read_idx =3D=3D oq->max_count) - read_idx =3D 0; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); } else { struct skb_shared_info *shinfo; u16 data_len; @@ -429,10 +432,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_de= vice *oct, * subsequent fragments contains only data. */ skb_put(skb, oq->max_single_buffer_size); - read_idx++; desc_used++; - if (read_idx =3D=3D oq->max_count) - read_idx =3D 0; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); =20 shinfo =3D skb_shinfo(skb); data_len =3D buff_info->len - oq->max_single_buffer_size; @@ -454,10 +455,8 @@ static int __octep_vf_oq_process_rx(struct octep_vf_de= vice *oct, buff_info->len, buff_info->len); buff_info->page =3D NULL; - read_idx++; desc_used++; - if (read_idx =3D=3D oq->max_count) - read_idx =3D 0; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); } } =20 --=20 2.53.0 From nobody Mon Jun 15 10:44:30 2026 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 77463345736 for ; Thu, 9 Apr 2026 18:40:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.47 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775760037; cv=none; b=gudvlKVzs9Xmo6pIujcbe9tdbJnGjEaEJZnDBqRGlI6XYhc20IwDU2fjdzxC+IU0LFnWmMjWG3mAQO3LyTiO5Wc1d63lCtA6UqdNlWtGjmzJGUh5M86BhAm3joIf/RzOrsHEpcuFV0PEBAyoGBPhqZVChyNwjwTXN/FB4KGvDh8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775760037; c=relaxed/simple; bh=LVgn0vBdkVsmYtOJ2Mv8Tab1Z8bSNEKNjFGxlFR9yQ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=bKnDFrVBtTqd0Z/pBdsFh+8D3yczhYP1NiitOds4dO/lcrE2QFzcGMgJkh0ltbqnyfPKdyi+WW7RpWCPDkDipPgeqSnhdi0sYVqovj3SHT8/iUTCQQtB8gCnw+0UNr6jflvazI6KHePoXoSgbPG81DyHqyu4Mzb7BFGPtiNb8II= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WhrvNbrl; arc=none smtp.client-ip=209.85.221.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WhrvNbrl" Received: by mail-wr1-f47.google.com with SMTP id ffacd0b85a97d-43d0deb7ad5so893441f8f.2 for ; Thu, 09 Apr 2026 11:40:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1775760034; x=1776364834; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cbSeM7rVE+r24N6osWe4SerhDWF0/QD9ts6cYUU6inY=; b=WhrvNbrly25+Togsaly3e4BXhhMpkO1Yt3BoLHXbHTjLF1r7DBhemt9VulCZIJesqc QiMML/vmORrziXZQ+Wzyks3sa8icaSZdq7DKAQAveM3PcGPnfI4996aLTSKaSdFqU7+E xRfiKn9Rr2IWbtJl5OQwA93lgP1DpDPwWyI++znrU7mgUcVFgPIguRkAhLtYL00brI/A 1IlYNXdCSyNSt0E58Q00PgAjiYtTl1HHub0RpdLJyOFMVklKZxHpybv1jGv5adBDDJAF ApOmi0XLioQxMbd8FMdD+9L91fx/7T8xjNtMPFuQrwi2w5kbV2VP/jqbLldFajdwSts9 2srg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1775760034; x=1776364834; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=cbSeM7rVE+r24N6osWe4SerhDWF0/QD9ts6cYUU6inY=; b=oaM9U6JkiJiCegbocZ3ZZ8LjIVXl3COZvJZB7DCC3xztJViGI17qqwPCeGKrYEApYW AQoMMQ8x3DlFsjEichJjvV+MJhjXKm/Chpo3j5KtUqbVcSLjgSOSHvCMp6E2p0Vp81of KgZv0G3lC82XcOMlVfW8tqBaIwzD9h5wBKDzKsgHQ/ZjjsjoQBLOKhfvktVfuqPxTeIR Izp7IzEkv82LdHFhRZX6LmbE/FdZX4kvwia3/ry5cyV49+I7fV9GG7Fok6qK0qLBXeZM w5e8UkHVxxmAFY6+dCI2XCMayD+WQKuRgEv9tGJcyzD8DQqX84l56k+DKKYtCrxj+UXx DDjg== X-Forwarded-Encrypted: i=1; AJvYcCU88rMJx+1kex6YlJd82eae+8z6xk06hAiKqZ0Jo8PJ8Vn+e62t9SBAqRO0QAFPmdMReSFva2NLKj/sxgY=@vger.kernel.org X-Gm-Message-State: AOJu0YwDT23b7KRLv0bsKw+WtI7KVXYpkeOD8PElv2wQQUxaKQNd1XV0 wVwdCLmt+elUW5BxY7XvYgAiNpSkiBRZ75vaZQCLqc1j0EtNATxp8sS4 X-Gm-Gg: AeBDiet8z52sPPnhK2fyoT12HoAR3ffqNpc4/pwFWW4qAMD/Lv4dBvKT2YhR5gaVWqg dlDnmRqIy3k2+oWPhXc6WKTK61UiR56w/IOLivALDI3WJBM+BMKaIexiVcoYcbvEWAmSqqzNjHJ AVDHnHV5WA6YEeRF5BjPWJf7WrLigXoSRN+Q71FRk8Z+n+eLtlAPWMfQVjoLmZf9MMP0FhF3Y01 apXyBrWL10OS1S7aW1uF5QNo+RbD/pFkRdJ2D/4omLspqlD8zA/O+X/ilrK74Y4qAj8cgYEaK3E Z8aF2M8y+ECSpeKHcmBYpK7+t5H9T4xMTeq0NSFRQjMdPbT1F53iN9R3pJbLjZqgOqW5g8FuRAK zUtNUcuUkdOC8Pn9Y2AznxgY/oGdfiqc0E+kuuV29WdruIqKP3uK3l9soaFdWhtwFBZ+8QEkVUR p+IipIwJNhHt+fX5Ilz7wxnyhlXgHsrU5wiceBJtFNygsjOEJGCv8CMfvIn1zZrnQAQUwB9Y2IF LK+eTku0fHD89cPR5Cz7wM= X-Received: by 2002:a05:6000:40dc:b0:439:bd70:610f with SMTP id ffacd0b85a97d-43d642bac24mr244448f8f.44.1775760033721; Thu, 09 Apr 2026 11:40:33 -0700 (PDT) Received: from dohko.chello.ie (188-141-5-72.dynamic.upc.ie. [188.141.5.72]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43d63e5d88bsm560563f8f.37.2026.04.09.11.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Apr 2026 11:40:33 -0700 (PDT) From: David Carlier To: netdev@vger.kernel.org Cc: vburru@marvell.com, sedara@marvell.com, srasheed@marvell.com, sburla@marvell.com, andrew+netdev@lunn.ch, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, horms@kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, David Carlier Subject: [PATCH net v2 2/2] octeon_ep_vf: add NULL check for napi_build_skb() Date: Thu, 9 Apr 2026 19:40:09 +0100 Message-ID: <20260409184009.930359-3-devnexen@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260409184009.930359-1-devnexen@gmail.com> References: <20260409184009.930359-1-devnexen@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" napi_build_skb() can return NULL on allocation failure. In __octep_vf_oq_process_rx(), the result is used directly without a NULL check in both the single-buffer and multi-fragment paths, leading to a NULL pointer dereference. Add NULL checks after both napi_build_skb() calls, properly advancing descriptors and consuming remaining fragments on failure. Fixes: 1cd3b407977c ("octeon_ep_vf: add Tx/Rx processing and interrupt supp= ort") Cc: stable@vger.kernel.org Signed-off-by: David Carlier --- .../marvell/octeon_ep_vf/octep_vf_rx.c | 30 +++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c b/driv= ers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c index 7bd1b9b8d7f5..d98247408242 100644 --- a/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c +++ b/drivers/net/ethernet/marvell/octeon_ep_vf/octep_vf_rx.c @@ -414,10 +414,15 @@ static int __octep_vf_oq_process_rx(struct octep_vf_d= evice *oct, data_offset =3D OCTEP_VF_OQ_RESP_HW_SIZE; rx_ol_flags =3D 0; } - rx_bytes +=3D buff_info->len; - if (buff_info->len <=3D oq->max_single_buffer_size) { skb =3D napi_build_skb((void *)resp_hw, PAGE_SIZE); + if (!skb) { + oq->stats->alloc_failures++; + desc_used++; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); + continue; + } + rx_bytes +=3D buff_info->len; skb_reserve(skb, data_offset); skb_put(skb, buff_info->len); desc_used++; @@ -427,6 +432,27 @@ static int __octep_vf_oq_process_rx(struct octep_vf_de= vice *oct, u16 data_len; =20 skb =3D napi_build_skb((void *)resp_hw, PAGE_SIZE); + if (!skb) { + oq->stats->alloc_failures++; + desc_used++; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); + data_len =3D buff_info->len - oq->max_single_buffer_size; + while (data_len) { + dma_unmap_page(oq->dev, oq->desc_ring[read_idx].buffer_ptr, + PAGE_SIZE, DMA_FROM_DEVICE); + buff_info =3D (struct octep_vf_rx_buffer *) + &oq->buff_info[read_idx]; + buff_info->page =3D NULL; + if (data_len < oq->buffer_size) + data_len =3D 0; + else + data_len -=3D oq->buffer_size; + desc_used++; + read_idx =3D octep_vf_oq_next_idx(oq, read_idx); + } + continue; + } + rx_bytes +=3D buff_info->len; skb_reserve(skb, data_offset); /* Head fragment includes response header(s); * subsequent fragments contains only data. --=20 2.53.0