Commit 1e78404b authored by Jeffrey Kardatzke's avatar Jeffrey Kardatzke Committed by Commit Bot

media/gpu/v4l2: Fix DCHECK when Initialize fails

This fixes a DCHECK that would occur if Initialize failed because then
in CreateWithOutputMode it would let the unique_ptr for the
image_processor fall out of scope and become deallocated; and we have a
sequence checker to ensure deallocation only happens on the task runner.
I would have used DeleteSoon, but that didn't seem possible because the
destructor was not public.

BUG=1050852
TEST=image_processor_test no longer DCHECKs on elm w/ 4.19 kernel

Change-Id: Ifae96c3a4206d8e94b7fdd6dd3e2ec571cc3465b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2051162Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Commit-Queue: J Kardatzke <jkardatzke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#741148}
parent d1d605f9
......@@ -392,8 +392,15 @@ V4L2ImageProcessorBackend::CreateWithOutputMode(
base::Unretained(image_processor.get()),
std::move(init_cb)));
done.Wait();
if (!success)
if (!success) {
// This needs to be destroyed on |backend_task_runner|.
backend_task_runner->PostTask(
FROM_HERE,
base::BindOnce(
base::DoNothing::Once<std::unique_ptr<ImageProcessorBackend>>(),
std::move(image_processor)));
return nullptr;
}
return image_processor;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment