From: Laurent Pinchart Date: Wed, 3 Jul 2013 10:49:06 +0000 (-0300) Subject: [media] v4l: async: Make it safe to unregister unregistered notifier X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=8e3fbfee23fffa2f50a36ef7b7d18092d0f57f6c;p=openwrt%2Fstaging%2Fblogic.git [media] v4l: async: Make it safe to unregister unregistered notifier Calling v4l2_async_notifier_unregister() on a notifier that hasn't been registered leads to a crash. To simplify drivers, make it safe to unregister a notifier that has not been registered. Signed-off-by: Laurent Pinchart Tested-by: Sylwester Nawrocki Acked-by: Sylwester Nawrocki Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/v4l2-core/v4l2-async.c b/drivers/media/v4l2-core/v4l2-async.c index b350ab99652c..10bb62cb8d7d 100644 --- a/drivers/media/v4l2-core/v4l2-async.c +++ b/drivers/media/v4l2-core/v4l2-async.c @@ -192,6 +192,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier) struct device *dev[n_subdev]; int i = 0; + if (!notifier->v4l2_dev) + return; + mutex_lock(&list_lock); list_del(¬ifier->list); @@ -225,6 +228,9 @@ void v4l2_async_notifier_unregister(struct v4l2_async_notifier *notifier) } put_device(d); } + + notifier->v4l2_dev = NULL; + /* * Don't care about the waiting list, it is initialised and populated * upon notifier registration.