* [PATCH 1/1] block: mtip32xx: set error code on failure
@ 2016-12-01 2:10 Pan Bian
2016-12-01 15:01 ` Jens Axboe
0 siblings, 1 reply; 2+ messages in thread
From: Pan Bian @ 2016-12-01 2:10 UTC (permalink / raw)
To: Jens Axboe, Asai Thambi SP, Selvan Mani, Rajesh Kumar Sambandam,
Vignesh Gunasekaran, Baoyou Xie, Keith Busch, Mike Christie,
Al Viro
Cc: linux-kernel, Pan Bian
Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188531. In function
mtip_block_initialize(), variable rv takes the return value, and its
value should be negative on errors. rv is initialized as 0 and is not
reset when the call to ida_pre_get() fails. So 0 may be returned.
The return value 0 indicates that there is no error, which may be
inconsistent with the execution status. This patch fixes the bug by
explicitly assigning -ENOMEM to rv on the branch that ida_pre_get()
fails.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/block/mtip32xx/mtip32xx.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index 3cfd879..36e70cb 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3937,8 +3937,10 @@ static int mtip_block_initialize(struct driver_data *dd)
/* Generate the disk name, implemented same as in sd.c */
do {
- if (!ida_pre_get(&rssd_index_ida, GFP_KERNEL))
+ if (!ida_pre_get(&rssd_index_ida, GFP_KERNEL)) {
+ rv = -ENOMEM;
goto ida_get_error;
+ }
spin_lock(&rssd_index_lock);
rv = ida_get_new(&rssd_index_ida, &index);
--
1.9.1
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH 1/1] block: mtip32xx: set error code on failure
2016-12-01 2:10 [PATCH 1/1] block: mtip32xx: set error code on failure Pan Bian
@ 2016-12-01 15:01 ` Jens Axboe
0 siblings, 0 replies; 2+ messages in thread
From: Jens Axboe @ 2016-12-01 15:01 UTC (permalink / raw)
To: Pan Bian, Asai Thambi SP, Selvan Mani, Rajesh Kumar Sambandam,
Vignesh Gunasekaran, Baoyou Xie, Keith Busch, Mike Christie,
Al Viro
Cc: linux-kernel
On 11/30/2016 07:10 PM, Pan Bian wrote:
> Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188531. In function
> mtip_block_initialize(), variable rv takes the return value, and its
> value should be negative on errors. rv is initialized as 0 and is not
> reset when the call to ida_pre_get() fails. So 0 may be returned.
> The return value 0 indicates that there is no error, which may be
> inconsistent with the execution status. This patch fixes the bug by
> explicitly assigning -ENOMEM to rv on the branch that ida_pre_get()
> fails.
Thanks, applied for 4.10.
--
Jens Axboe
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-12-01 15:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-01 2:10 [PATCH 1/1] block: mtip32xx: set error code on failure Pan Bian
2016-12-01 15:01 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®