Re: [PATCH] block: rsxx: fix error return code of rsxx_pci_probe()

From: Jens Axboe
Date: Tue Mar 09 2021 - 16:00:11 EST


On 3/8/21 3:05 AM, Jia-Ju Bai wrote:
> Some error handling segments of rsxx_pci_probe() do not return error code,
> so add error code for these segments.
>
> Fixes: 8722ff8cdbfa ("block: IBM RamSan 70/80 device driver")
> Reported-by: TOTE Robot <oslab@xxxxxxxxxxxxxxx>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@xxxxxxxxx>
> ---
> drivers/block/rsxx/core.c | 18 +++++++++++++++---
> 1 file changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c
> index 63f549889f87..6b3b9b31a3e8 100644
> --- a/drivers/block/rsxx/core.c
> +++ b/drivers/block/rsxx/core.c
> @@ -760,13 +760,17 @@ static int rsxx_pci_probe(struct pci_dev *dev,
> pci_set_drvdata(dev, card);
>
> st = ida_alloc(&rsxx_disk_ida, GFP_KERNEL);
> - if (st < 0)
> + if (st < 0) {
> + st = -ENOMEM;
> goto failed_ida_get;
> + }
> card->disk_id = st;
>
> st = pci_enable_device(dev);
> - if (st)
> + if (st) {
> + st = -EIO;
> goto failed_enable;
> + }
>
> pci_set_master(dev);

Maybe there are some valid parts to the patch, but the two above at
least make no sense - we're returning the error here as passed from
ida_alloc or pci_enable_device, why are you overriding them?

--
Jens Axboe