Netdev List
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Ariel Elior <Ariel.Elior@cavium.com>
Cc: everest-linux-l2@cavium.com, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH net-next] qed: Set error code for allocation failures
Date: Fri, 27 Oct 2017 09:40:20 +0300	[thread overview]
Message-ID: <20171027064020.aq52ue4kfp5htrb5@mwanda> (raw)

There are several places where we accidentally return success when
kcalloc() fails.

Fixes: fcb39f6c10b2 ("qed: Add mpa buffer descriptors for storing and processing mpa fpdus")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
index 409041eab189..6366f2ef82b7 100644
--- a/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
+++ b/drivers/net/ethernet/qlogic/qed/qed_iwarp.c
@@ -2585,7 +2585,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
 	struct qed_ll2_cbs cbs;
 	u32 mpa_buff_size;
 	u16 n_ooo_bufs;
-	int rc = 0;
+	int rc;
 	int i;
 
 	iwarp_info = &p_hwfn->p_rdma_info->iwarp;
@@ -2696,6 +2696,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
 	if (rc)
 		goto err;
 
+	rc = -ENOMEM;
 	iwarp_info->partial_fpdus = kcalloc((u16)p_hwfn->p_rdma_info->num_qps,
 					    sizeof(*iwarp_info->partial_fpdus),
 					    GFP_KERNEL);
@@ -2724,7 +2725,7 @@ qed_iwarp_ll2_start(struct qed_hwfn *p_hwfn,
 	for (i = 0; i < data.input.rx_num_desc; i++)
 		list_add_tail(&iwarp_info->mpa_bufs[i].list_entry,
 			      &iwarp_info->mpa_buf_list);
-	return rc;
+	return 0;
 err:
 	qed_iwarp_ll2_stop(p_hwfn, p_ptt);
 

             reply	other threads:[~2017-10-27  6:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-27  6:40 Dan Carpenter [this message]
2017-10-27  9:32 ` [PATCH net-next] qed: Set error code for allocation failures Yunsheng Lin
2017-10-27 11:52   ` Dan Carpenter
2017-10-28  5:50     ` Yunsheng Lin
2017-10-29  7:45     ` Kalderon, Michal
2017-10-29  7:50 ` Kalderon, Michal

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=20171027064020.aq52ue4kfp5htrb5@mwanda \
    --to=dan.carpenter@oracle.com \
    --cc=Ariel.Elior@cavium.com \
    --cc=everest-linux-l2@cavium.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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