Skip to content

Commit

Permalink
pf: fix error codes in pf_init_unit()
Browse files Browse the repository at this point in the history
Return a negative error code instead of success on these error paths.

Fixes: fb367e6 ("pf: cleanup initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20211001122654.GB2283@kili
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Dan Carpenter authored and Jens Axboe committed Oct 18, 2021
1 parent d0ac7a3 commit cfc03ea
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions drivers/block/paride/pf.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit cfc03ea

Please sign in to comment.