Linux block layer
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Tim Waugh <tim@cyberelk.net>, Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [PATCH] pf: fix error codes in pf_init_unit()
Date: Fri, 1 Oct 2021 15:26:54 +0300	[thread overview]
Message-ID: <20211001122654.GB2283@kili> (raw)

Return a negative error code instead of success on these error paths.

Fixes: 327638dec0ce ("pf: cleanup initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/block/paride/pf.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/block/paride/pf.c b/drivers/block/paride/pf.c
index 380d80e507c7..bf8d0ef41a0a 100644
--- a/drivers/block/paride/pf.c
+++ b/drivers/block/paride/pf.c
@@ -651,9 +651,9 @@ static int pf_identify(struct pf_unit *pf)
 	return 0;
 }
 
-/*	returns  0, with id set if drive is detected
-	        -1, if drive detection failed
-*/
+/*
+ * returns 0, with id set if drive is detected, otherwise an error code.
+ */
 static int pf_probe(struct pf_unit *pf)
 {
 	if (pf->drive == -1) {
@@ -675,7 +675,7 @@ static int pf_probe(struct pf_unit *pf)
 			if (!pf_identify(pf))
 				return 0;
 	}
-	return -1;
+	return -ENODEV;
 }
 
 /* The i/o request engine */
@@ -957,9 +957,12 @@ static int __init pf_init_unit(struct pf_unit *pf, bool autoprobe, int port,
 	snprintf(pf->name, PF_NAMELEN, "%s%d", name, disk->first_minor);
 
 	if (!pi_init(pf->pi, autoprobe, port, mode, unit, protocol, delay,
-			pf_scratch, PI_PF, verbose, pf->name))
+			pf_scratch, PI_PF, verbose, pf->name)) {
+		ret = -ENODEV;
 		goto out_free_disk;
-	if (pf_probe(pf))
+	}
+	ret = pf_probe(pf);
+	if (ret)
 		goto out_pi_release;
 
 	ret = add_disk(disk);
-- 
2.20.1


             reply	other threads:[~2021-10-01 12:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-01 12:26 Dan Carpenter [this message]
2021-10-01 19:34 ` [PATCH] pf: fix error codes in pf_init_unit() Jens Axboe

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=20211001122654.GB2283@kili \
    --to=dan.carpenter@oracle.com \
    --cc=axboe@kernel.dk \
    --cc=hch@lst.de \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=tim@cyberelk.net \
    /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