* [PATCH v3] block: wrong return value
@ 2014-10-23 16:46 Sudip Mukherjee
2014-10-28 17:22 ` Sudip Mukherjee
0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee @ 2014-10-23 16:46 UTC (permalink / raw)
To: Jens Axboe; +Cc: Sudip Mukherjee, linux-kernel
while compiling integer err was showing as a set but unused variable.
elevator_init_fn can be either cfq_init_queue or deadline_init_queue
or noop_init_queue.
all three of these functions are returning -ENOMEM if they fail to
allocate the queue.
so we should actually be returning the error code rather than
returning 0 always.
Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
---
change in v2: added elevator_put
change in v3: remove unneeded initialization of err
block/elevator.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/block/elevator.c b/block/elevator.c
index 24c28b6..afa3b03 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -229,7 +229,9 @@ int elevator_init(struct request_queue *q, char *name)
}
err = e->ops.elevator_init_fn(q, e);
- return 0;
+ if (err)
+ elevator_put(e);
+ return err;
}
EXPORT_SYMBOL(elevator_init);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v3] block: wrong return value
2014-10-23 16:46 [PATCH v3] block: wrong return value Sudip Mukherjee
@ 2014-10-28 17:22 ` Sudip Mukherjee
2014-10-28 17:26 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: Sudip Mukherjee @ 2014-10-28 17:22 UTC (permalink / raw)
To: Jens Axboe; +Cc: linux-kernel
On Thu, Oct 23, 2014 at 10:16:48PM +0530, Sudip Mukherjee wrote:
> while compiling integer err was showing as a set but unused variable.
> elevator_init_fn can be either cfq_init_queue or deadline_init_queue
> or noop_init_queue.
> all three of these functions are returning -ENOMEM if they fail to
> allocate the queue.
> so we should actually be returning the error code rather than
> returning 0 always.
i have one doubt. shouldn't this patch be marked for stable also?
thanks
sudip
>
> Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org>
> ---
>
> change in v2: added elevator_put
> change in v3: remove unneeded initialization of err
>
> block/elevator.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/block/elevator.c b/block/elevator.c
> index 24c28b6..afa3b03 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -229,7 +229,9 @@ int elevator_init(struct request_queue *q, char *name)
> }
>
> err = e->ops.elevator_init_fn(q, e);
> - return 0;
> + if (err)
> + elevator_put(e);
> + return err;
> }
> EXPORT_SYMBOL(elevator_init);
>
> --
> 1.8.1.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v3] block: wrong return value
2014-10-28 17:22 ` Sudip Mukherjee
@ 2014-10-28 17:26 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-10-28 17:26 UTC (permalink / raw)
To: Sudip Mukherjee; +Cc: linux-kernel
On 2014-10-28 11:22, Sudip Mukherjee wrote:
> On Thu, Oct 23, 2014 at 10:16:48PM +0530, Sudip Mukherjee wrote:
>> while compiling integer err was showing as a set but unused variable.
>> elevator_init_fn can be either cfq_init_queue or deadline_init_queue
>> or noop_init_queue.
>> all three of these functions are returning -ENOMEM if they fail to
>> allocate the queue.
>> so we should actually be returning the error code rather than
>> returning 0 always.
> i have one doubt. shouldn't this patch be marked for stable also?
It would not hurt to mark it as stable, but on the other hand, this
probably never triggered a problem for anyone. So it's not a critical
fix by any stretch.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-10-28 17:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-23 16:46 [PATCH v3] block: wrong return value Sudip Mukherjee
2014-10-28 17:22 ` Sudip Mukherjee
2014-10-28 17:26 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox