netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
To: netdev@vger.kernel.org
Cc: Dany Madden <drt@linux.ibm.com>,
	Rick Lindsley <ricklind@linux.ibm.com>,
	sukadev@linux.ibm.com, Brian King <brking@linux.ibm.com>,
	cforno12@linux.ibm.com
Subject: [PATCH net 4/7] ibmvnic: account for bufs already saved in indir_buf
Date: Wed, 23 Jun 2021 21:13:13 -0700	[thread overview]
Message-ID: <20210624041316.567622-5-sukadev@linux.ibm.com> (raw)
In-Reply-To: <20210624041316.567622-1-sukadev@linux.ibm.com>

This fixes a crash in replenish_rx_pool() when called from ibmvnic_poll()
after a previous call to replenish_rx_pool() encountered an error when
allocating a socket buffer.

Thanks to Rick Lindsley and Dany Madden for helping debug the crash.

Fixes: 4f0b6812e9b9 ("ibmvnic: Introduce batched RX buffer descriptor transmission")
Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.ibm.com>
---
 drivers/net/ethernet/ibm/ibmvnic.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ibm/ibmvnic.c b/drivers/net/ethernet/ibm/ibmvnic.c
index fa402e20c137..b1d7caaa4fb7 100644
--- a/drivers/net/ethernet/ibm/ibmvnic.c
+++ b/drivers/net/ethernet/ibm/ibmvnic.c
@@ -351,7 +351,14 @@ static void replenish_rx_pool(struct ibmvnic_adapter *adapter,
 
 	rx_scrq = adapter->rx_scrq[pool->index];
 	ind_bufp = &rx_scrq->ind_buf;
-	for (i = 0; i < count; ++i) {
+
+	/* netdev_skb_alloc() could have failed after we saved a few skbs
+	 * in the indir_buf and we would not have sent them to VIOS yet.
+	 * To account for them, start the loop at ind_bufp->index rather
+	 * than 0. If we pushed all the skbs to VIOS, ind_bufp->index will
+	 * be 0.
+	 */
+	for (i = ind_bufp->index; i < count; ++i) {
 		skb = netdev_alloc_skb(adapter->netdev, pool->buff_size);
 		if (!skb) {
 			dev_err(dev, "Couldn't replenish rx buff\n");
-- 
2.31.1


  parent reply	other threads:[~2021-06-24  4:14 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-24  4:13 [PATCH net 0/7] ibmvnic: Assorted bug fixes Sukadev Bhattiprolu
2021-06-24  4:13 ` [PATCH net 1/7] Revert "ibmvnic: simplify reset_long_term_buff function" Sukadev Bhattiprolu
2021-06-24  6:07   ` Lijun Pan
2021-06-24 16:07     ` Sukadev Bhattiprolu
2021-06-24  4:13 ` [PATCH net 2/7] Revert "ibmvnic: remove duplicate napi_schedule call in open function" Sukadev Bhattiprolu
2021-06-24  6:20   ` Lijun Pan
2021-06-24  6:42     ` Rick Lindsley
2021-06-24  7:07     ` Rick Lindsley
2021-06-24  7:02   ` Johaan Smith
2021-06-24  7:28     ` Rick Lindsley
2021-06-24 17:05       ` Lijun Pan
2021-06-24 18:18         ` Dany Madden
2021-06-24 23:33         ` Rick Lindsley
2021-06-24 16:53     ` Lijun Pan
2021-06-24  4:13 ` [PATCH net 3/7] ibmvnic: clean pending indirect buffs during reset Sukadev Bhattiprolu
2021-06-24  4:13 ` Sukadev Bhattiprolu [this message]
2021-06-24  4:13 ` [PATCH net 5/7] ibmvnic: set ltb->buff to NULL after freeing Sukadev Bhattiprolu
2021-06-24  4:13 ` [PATCH net 6/7] ibmvnic: free tx_pool if tso_pool alloc fails Sukadev Bhattiprolu
2021-06-24  4:13 ` [PATCH net 7/7] ibmvnic: parenthesize a check Sukadev Bhattiprolu
2021-06-24  5:50   ` Lijun Pan
2021-06-24 18:30 ` [PATCH net 0/7] ibmvnic: Assorted bug fixes patchwork-bot+netdevbpf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210624041316.567622-5-sukadev@linux.ibm.com \
    --to=sukadev@linux.ibm.com \
    --cc=brking@linux.ibm.com \
    --cc=cforno12@linux.ibm.com \
    --cc=drt@linux.ibm.com \
    --cc=netdev@vger.kernel.org \
    --cc=ricklind@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).