]> git.baikalelectronics.ru Git - kernel.git/commit
media: ti-vpe: cal: fix a kernel oops when unloading module
authorBenoit Parrot <bparrot@ti.com>
Fri, 6 Mar 2020 13:08:39 +0000 (14:08 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 17 Apr 2020 08:50:08 +0000 (10:50 +0200)
commit633dbb9f4af9001643f11e5710800b02afadf8b8
treebf9b6cdfe67aa3e6c9f662c92ce76a0762f19b60
parent5c20dce5912d58c487fe2590e12616dac34769a1
media: ti-vpe: cal: fix a kernel oops when unloading module

commit 7e84e3b33bc2dbe4dd3051649a61a12543365635 upstream.

After the switch to use v4l2_async_notifier_add_subdev() and
v4l2_async_notifier_cleanup(), unloading the ti_cal module would cause a
kernel oops.

This was root cause to the fact that v4l2_async_notifier_cleanup() tries
to kfree the asd pointer passed into v4l2_async_notifier_add_subdev().

In our case the asd reference was from a statically allocated struct.
So in effect v4l2_async_notifier_cleanup() was trying to free a pointer
that was not kalloc.

So here we switch to using a kzalloc struct instead of a static one.
To achieve this we re-order some of the calls to prevent asd allocation
from leaking.

Fixes: 3c1618f649dd ("media: platform: Switch to v4l2_async_notifier_add_subdev")
Cc: stable@vger.kernel.org
Signed-off-by: Benoit Parrot <bparrot@ti.com>
Reviewed-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/media/platform/ti-vpe/cal.c