2015-04-23 07:44:54

by Chao Yu

[permalink] [raw]
Subject: [PATCH] elevator: remove unneeded kfree in error path of elevator_alloc

In elevator_alloc, if we fail to allocate memory for storing elevator
queue, our eq pointer must be NULL, we do not need to release it in error
path, so remove it.

Signed-off-by: Chao Yu <[email protected]>
---
block/elevator.c | 1 -
1 file changed, 1 deletion(-)

diff --git a/block/elevator.c b/block/elevator.c
index 59794d0..d146a5e 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -166,7 +166,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,

return eq;
err:
- kfree(eq);
elevator_put(e);
return NULL;
}
--
2.3.3


2015-04-23 14:58:29

by Jeff Moyer

[permalink] [raw]
Subject: Re: [PATCH] elevator: remove unneeded kfree in error path of elevator_alloc

Chao Yu <[email protected]> writes:

> In elevator_alloc, if we fail to allocate memory for storing elevator
> queue, our eq pointer must be NULL, we do not need to release it in error
> path, so remove it.
>
> Signed-off-by: Chao Yu <[email protected]>
> ---
> block/elevator.c | 1 -
> 1 file changed, 1 deletion(-)
>
> diff --git a/block/elevator.c b/block/elevator.c
> index 59794d0..d146a5e 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -166,7 +166,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
>
> return eq;
> err:
> - kfree(eq);
> elevator_put(e);
> return NULL;
> }

Acked-by: Jeff Moyer <[email protected]>