* [PATCH] block: rsxx: fix error return code of rsxx_pci_probe()
@ 2021-03-08 10:05 Jia-Ju Bai
2021-03-09 20:59 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-08 10:05 UTC (permalink / raw)
To: josh.h.morris, pjk1939, axboe; +Cc: linux-block, linux-kernel, Jia-Ju Bai
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@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
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);
@@ -774,6 +778,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
if (st) {
dev_err(CARD_TO_DEV(card),
"No usable DMA configuration,aborting\n");
+ st = -EIO;
goto failed_dma_mask;
}
@@ -781,6 +786,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
if (st) {
dev_err(CARD_TO_DEV(card),
"Failed to request memory region\n");
+ st = -EIO;
goto failed_request_regions;
}
@@ -817,6 +823,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
if (st) {
dev_err(CARD_TO_DEV(card),
"Failed requesting IRQ%d\n", dev->irq);
+ st = -EINVAL;
goto failed_irq;
}
@@ -824,6 +831,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
st = rsxx_creg_setup(card);
if (st) {
dev_err(CARD_TO_DEV(card), "Failed to setup creg interface.\n");
+ st = -EINVAL;
goto failed_creg_setup;
}
@@ -862,6 +870,7 @@ static int rsxx_pci_probe(struct pci_dev *dev,
if (st) {
dev_info(CARD_TO_DEV(card),
"Failed to setup DMA engine\n");
+ st = -EINVAL;
goto failed_dma_setup;
}
@@ -869,14 +878,17 @@ static int rsxx_pci_probe(struct pci_dev *dev,
card->event_wq = create_singlethread_workqueue(DRIVER_NAME"_event");
if (!card->event_wq) {
dev_err(CARD_TO_DEV(card), "Failed card event setup.\n");
+ st = -ENOMEM;
goto failed_event_handler;
}
INIT_WORK(&card->event_work, card_event_handler);
st = rsxx_setup_dev(card);
- if (st)
+ if (st) {
+ st = -EINVAL;
goto failed_create_dev;
+ }
rsxx_get_card_state(card, &card->state);
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] block: rsxx: fix error return code of rsxx_pci_probe()
2021-03-08 10:05 [PATCH] block: rsxx: fix error return code of rsxx_pci_probe() Jia-Ju Bai
@ 2021-03-09 20:59 ` Jens Axboe
2021-03-10 1:13 ` Jia-Ju Bai
0 siblings, 1 reply; 3+ messages in thread
From: Jens Axboe @ 2021-03-09 20:59 UTC (permalink / raw)
To: Jia-Ju Bai, josh.h.morris, pjk1939; +Cc: linux-block, linux-kernel
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@tsinghua.edu.cn>
> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
> ---
> 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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] block: rsxx: fix error return code of rsxx_pci_probe()
2021-03-09 20:59 ` Jens Axboe
@ 2021-03-10 1:13 ` Jia-Ju Bai
0 siblings, 0 replies; 3+ messages in thread
From: Jia-Ju Bai @ 2021-03-10 1:13 UTC (permalink / raw)
To: Jens Axboe, josh.h.morris, pjk1939; +Cc: linux-block, linux-kernel
On 2021/3/10 4:59, Jens Axboe wrote:
> 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@tsinghua.edu.cn>
>> Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
>> ---
>> 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?
>
Ah, sorry for these incorrect parts...
I will send a new patch.
Best wishes,
Jia-Ju Bai
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-03-10 1:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-08 10:05 [PATCH] block: rsxx: fix error return code of rsxx_pci_probe() Jia-Ju Bai
2021-03-09 20:59 ` Jens Axboe
2021-03-10 1:13 ` Jia-Ju Bai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).