* [PATCH] elevator: fix double release for elevator module
@ 2015-04-23 9:23 Chao Yu
2015-04-23 14:59 ` Jeff Moyer
0 siblings, 1 reply; 4+ messages in thread
From: Chao Yu @ 2015-04-23 9:23 UTC (permalink / raw)
To: axboe; +Cc: linux-kernel
Our issue is descripted in below call path:
->elevator_init
->elevator_init_fn
->{cfq,deadline,noop}_init_queue
->elevator_alloc
->kzalloc_node
fail to call kzalloc_node and then put module in elevator_alloc;
fail to call elevator_init_fn and then put module again in elevator_init.
Remove elevator_put invoking in error path of elevator_alloc to avoid
double release issue.
Signed-off-by: Chao Yu <chao2.yu@samsung.com>
---
block/elevator.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/block/elevator.c b/block/elevator.c
index d146a5e..8985038 100644
--- a/block/elevator.c
+++ b/block/elevator.c
@@ -157,7 +157,7 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
eq = kzalloc_node(sizeof(*eq), GFP_KERNEL, q->node);
if (unlikely(!eq))
- goto err;
+ return NULL;
eq->type = e;
kobject_init(&eq->kobj, &elv_ktype);
@@ -165,9 +165,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
hash_init(eq->hash);
return eq;
-err:
- elevator_put(e);
- return NULL;
}
EXPORT_SYMBOL(elevator_alloc);
--
2.3.3
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] elevator: fix double release for elevator module
2015-04-23 9:23 [PATCH] elevator: fix double release for elevator module Chao Yu
@ 2015-04-23 14:59 ` Jeff Moyer
2015-04-23 16:49 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Jeff Moyer @ 2015-04-23 14:59 UTC (permalink / raw)
To: Chao Yu; +Cc: axboe, linux-kernel
Chao Yu <chao2.yu@samsung.com> writes:
> Our issue is descripted in below call path:
> ->elevator_init
> ->elevator_init_fn
> ->{cfq,deadline,noop}_init_queue
> ->elevator_alloc
> ->kzalloc_node
> fail to call kzalloc_node and then put module in elevator_alloc;
> fail to call elevator_init_fn and then put module again in elevator_init.
>
> Remove elevator_put invoking in error path of elevator_alloc to avoid
> double release issue.
>
> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> ---
> block/elevator.c | 5 +----
> 1 file changed, 1 insertion(+), 4 deletions(-)
>
> diff --git a/block/elevator.c b/block/elevator.c
> index d146a5e..8985038 100644
> --- a/block/elevator.c
> +++ b/block/elevator.c
> @@ -157,7 +157,7 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
>
> eq = kzalloc_node(sizeof(*eq), GFP_KERNEL, q->node);
> if (unlikely(!eq))
> - goto err;
> + return NULL;
>
> eq->type = e;
> kobject_init(&eq->kobj, &elv_ktype);
> @@ -165,9 +165,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
> hash_init(eq->hash);
>
> return eq;
> -err:
> - elevator_put(e);
> - return NULL;
> }
> EXPORT_SYMBOL(elevator_alloc);
You could have posted the two patches together, as they are related.
Anyway, looks good to me.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] elevator: fix double release for elevator module
2015-04-23 14:59 ` Jeff Moyer
@ 2015-04-23 16:49 ` Jens Axboe
2015-04-24 1:28 ` Chao Yu
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2015-04-23 16:49 UTC (permalink / raw)
To: Jeff Moyer, Chao Yu; +Cc: linux-kernel
On 04/23/2015 08:59 AM, Jeff Moyer wrote:
> Chao Yu <chao2.yu@samsung.com> writes:
>
>> Our issue is descripted in below call path:
>> ->elevator_init
>> ->elevator_init_fn
>> ->{cfq,deadline,noop}_init_queue
>> ->elevator_alloc
>> ->kzalloc_node
>> fail to call kzalloc_node and then put module in elevator_alloc;
>> fail to call elevator_init_fn and then put module again in elevator_init.
>>
>> Remove elevator_put invoking in error path of elevator_alloc to avoid
>> double release issue.
>>
>> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
>> ---
>> block/elevator.c | 5 +----
>> 1 file changed, 1 insertion(+), 4 deletions(-)
>>
>> diff --git a/block/elevator.c b/block/elevator.c
>> index d146a5e..8985038 100644
>> --- a/block/elevator.c
>> +++ b/block/elevator.c
>> @@ -157,7 +157,7 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
>>
>> eq = kzalloc_node(sizeof(*eq), GFP_KERNEL, q->node);
>> if (unlikely(!eq))
>> - goto err;
>> + return NULL;
>>
>> eq->type = e;
>> kobject_init(&eq->kobj, &elv_ktype);
>> @@ -165,9 +165,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
>> hash_init(eq->hash);
>>
>> return eq;
>> -err:
>> - elevator_put(e);
>> - return NULL;
>> }
>> EXPORT_SYMBOL(elevator_alloc);
>
> You could have posted the two patches together, as they are related.
> Anyway, looks good to me.
>
> Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
Agree, it should be one patch. I've combined them, and applied the fix
for 4.1. Thanks.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread* RE: [PATCH] elevator: fix double release for elevator module
2015-04-23 16:49 ` Jens Axboe
@ 2015-04-24 1:28 ` Chao Yu
0 siblings, 0 replies; 4+ messages in thread
From: Chao Yu @ 2015-04-24 1:28 UTC (permalink / raw)
To: 'Jens Axboe', 'Jeff Moyer'; +Cc: linux-kernel
Hi Jens and Jeff,
Thanks for your review and help! :)
Regards,
> -----Original Message-----
> From: Jens Axboe [mailto:axboe@kernel.dk]
> Sent: Friday, April 24, 2015 12:49 AM
> To: Jeff Moyer; Chao Yu
> Cc: linux-kernel@vger.kernel.org
> Subject: Re: [PATCH] elevator: fix double release for elevator module
>
> On 04/23/2015 08:59 AM, Jeff Moyer wrote:
> > Chao Yu <chao2.yu@samsung.com> writes:
> >
> >> Our issue is descripted in below call path:
> >> ->elevator_init
> >> ->elevator_init_fn
> >> ->{cfq,deadline,noop}_init_queue
> >> ->elevator_alloc
> >> ->kzalloc_node
> >> fail to call kzalloc_node and then put module in elevator_alloc;
> >> fail to call elevator_init_fn and then put module again in elevator_init.
> >>
> >> Remove elevator_put invoking in error path of elevator_alloc to avoid
> >> double release issue.
> >>
> >> Signed-off-by: Chao Yu <chao2.yu@samsung.com>
> >> ---
> >> block/elevator.c | 5 +----
> >> 1 file changed, 1 insertion(+), 4 deletions(-)
> >>
> >> diff --git a/block/elevator.c b/block/elevator.c
> >> index d146a5e..8985038 100644
> >> --- a/block/elevator.c
> >> +++ b/block/elevator.c
> >> @@ -157,7 +157,7 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
> >>
> >> eq = kzalloc_node(sizeof(*eq), GFP_KERNEL, q->node);
> >> if (unlikely(!eq))
> >> - goto err;
> >> + return NULL;
> >>
> >> eq->type = e;
> >> kobject_init(&eq->kobj, &elv_ktype);
> >> @@ -165,9 +165,6 @@ struct elevator_queue *elevator_alloc(struct request_queue *q,
> >> hash_init(eq->hash);
> >>
> >> return eq;
> >> -err:
> >> - elevator_put(e);
> >> - return NULL;
> >> }
> >> EXPORT_SYMBOL(elevator_alloc);
> >
> > You could have posted the two patches together, as they are related.
> > Anyway, looks good to me.
> >
> > Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
>
> Agree, it should be one patch. I've combined them, and applied the fix
> for 4.1. Thanks.
>
> --
> Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-24 1:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-23 9:23 [PATCH] elevator: fix double release for elevator module Chao Yu
2015-04-23 14:59 ` Jeff Moyer
2015-04-23 16:49 ` Jens Axboe
2015-04-24 1:28 ` Chao Yu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox