linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zheyu Ma <zheyuma97@gmail.com>
To: rajur@chelsio.com, davem@davemloft.net, kuba@kernel.org
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Zheyu Ma <zheyuma97@gmail.com>
Subject: [PATCH] net: cxgb3: Fix an error code when probing the driver
Date: Sat,  5 Mar 2022 14:24:44 +0000	[thread overview]
Message-ID: <1646490284-22791-1-git-send-email-zheyuma97@gmail.com> (raw)

During the process of driver probing, probe function should return < 0
for failure, otherwise kernel will treat value >= 0 as success.

Therefore, the driver should set 'err' to -EINVAL when
'adapter->registered_device_map' is NULL. Otherwise kernel will assume
that the driver has been successfully probed and will cause unexpected
errors.

Signed-off-by: Zheyu Ma <zheyuma97@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index bfffcaeee624..662af61fc723 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -3346,6 +3346,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	}
 	if (!adapter->registered_device_map) {
 		dev_err(&pdev->dev, "could not register any net devices\n");
+		err = -EINVAL;
 		goto out_free_dev;
 	}
 
-- 
2.25.1


             reply	other threads:[~2022-03-05 14:25 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-05 14:24 Zheyu Ma [this message]
2022-03-05 15:40 ` [PATCH] net: cxgb3: Fix an error code when probing the driver Andrew Lunn
2022-03-06  5:56 ` [PATCH v2] " Zheyu Ma
2022-03-06 15:15   ` Andrew Lunn
2022-03-08  6:30   ` 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=1646490284-22791-1-git-send-email-zheyuma97@gmail.com \
    --to=zheyuma97@gmail.com \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=rajur@chelsio.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).