Message ID | 20221017065321.2846017-3-yebin10@huawei.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | fix possible memleak in '__blk_trace_remove' | expand |
Hi, 在 2022/10/17 14:53, Ye Bin 写道: > To solve above issues, reference commit '5afedf670caf', first stop block trace > when block trace state is 'Blktrace_running' in '__blk_trace_remove'. Will it be much simpler if we just return -EBUSY in blk_trace_remove if state is still running? And similar checking in blk_trace_setup. Thanks, Kuai
On Mon, Oct 17, 2022 at 02:53:20PM +0800, Ye Bin wrote: > + if (bt->trace_state == Blktrace_running) > + blk_trace_switch_state(bt, 0); AFAICS blk_trace_switch_state already has that state check, so there should be no need to duplicate it here. I think having this call in blk_trace_cleanup itself might be a little more obvious, too.
diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index edd83e213580..0d93a0110ab5 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -395,8 +395,10 @@ static int __blk_trace_remove(struct request_queue *q) if (!bt) return -EINVAL; - if (bt->trace_state != Blktrace_running) - blk_trace_cleanup(q, bt); + if (bt->trace_state == Blktrace_running) + blk_trace_switch_state(bt, 0); + + blk_trace_cleanup(q, bt); return 0; }