Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

pf: fix error codes in pf_init_unit()

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

Fixes: fb367e6baeb0 ("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>

authored by

Dan Carpenter and committed by
Jens Axboe
cfc03eab d0ac7a30

+9 -6
+9 -6
drivers/block/paride/pf.c
··· 651 651 return 0; 652 652 } 653 653 654 - /* returns 0, with id set if drive is detected 655 - -1, if drive detection failed 656 - */ 654 + /* 655 + * returns 0, with id set if drive is detected, otherwise an error code. 656 + */ 657 657 static int pf_probe(struct pf_unit *pf) 658 658 { 659 659 if (pf->drive == -1) { ··· 675 675 if (!pf_identify(pf)) 676 676 return 0; 677 677 } 678 - return -1; 678 + return -ENODEV; 679 679 } 680 680 681 681 /* The i/o request engine */ ··· 957 957 snprintf(pf->name, PF_NAMELEN, "%s%d", name, disk->first_minor); 958 958 959 959 if (!pi_init(pf->pi, autoprobe, port, mode, unit, protocol, delay, 960 - pf_scratch, PI_PF, verbose, pf->name)) 960 + pf_scratch, PI_PF, verbose, pf->name)) { 961 + ret = -ENODEV; 961 962 goto out_free_disk; 962 - if (pf_probe(pf)) 963 + } 964 + ret = pf_probe(pf); 965 + if (ret) 963 966 goto out_pi_release; 964 967 965 968 ret = add_disk(disk);