Skip to content

Commit

Permalink
pcd: fix error codes in pcd_init_unit()
Browse files Browse the repository at this point in the history
commit d0ac7a3 upstream.

Return -ENODEV on these error paths instead of returning success.

Fixes: af761f2 ("pcd: cleanup initialization")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20211001122623.GA2283@kili
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Dan Carpenter authored and Greg Kroah-Hartman committed Sep 19, 2023
1 parent 893978f commit 0c0d79f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/block/paride/pcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,8 +613,7 @@ static int pcd_identify(struct pcd_unit *cd)
}

/*
* 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 pcd_probe(struct pcd_unit *cd, int ms)
{
Expand All @@ -627,7 +626,7 @@ static int pcd_probe(struct pcd_unit *cd, int ms)
if (!pcd_reset(cd) && !pcd_identify(cd))
return 0;
}
return -1;
return -ENODEV;
}

static int pcd_probe_capabilities(struct pcd_unit *cd)
Expand Down Expand Up @@ -933,9 +932,12 @@ static int pcd_init_unit(struct pcd_unit *cd, bool autoprobe, int port,
disk->event_flags = DISK_EVENT_FLAG_BLOCK_ON_EXCL_WRITE;

if (!pi_init(cd->pi, autoprobe, port, mode, unit, protocol, delay,
pcd_buffer, PI_PCD, verbose, cd->name))
pcd_buffer, PI_PCD, verbose, cd->name)) {
ret = -ENODEV;
goto out_free_disk;
if (pcd_probe(cd, ms))
}
ret = pcd_probe(cd, ms);
if (ret)
goto out_pi_release;

cd->present = 1;
Expand Down

0 comments on commit 0c0d79f

Please sign in to comment.