Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

media: cec-notifier: clear cec_adap in cec_notifier_unregister

If cec_notifier_cec_adap_unregister() is called before
cec_unregister_adapter() then everything is OK (and this is the
case today). But if it is the other way around, then
cec_notifier_unregister() is called first, and that doesn't
set n->cec_adap to NULL.

So if e.g. cec_notifier_set_phys_addr() is called after
cec_notifier_unregister() but before cec_unregister_adapter()
then n->cec_adap points to an unregistered and likely deleted
cec adapter. So just set n->cec_adap->notifier and n->cec_adap
to NULL for rubustness.

Eventually cec_notifier_unregister will disappear and this will
be simplified substantially.

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>

authored by

Hans Verkuil and committed by
Mauro Carvalho Chehab
14d55116 8f4b5b0a

+2
+2
drivers/media/cec/cec-notifier.c
··· 218 218 219 219 mutex_lock(&n->lock); 220 220 n->callback = NULL; 221 + n->cec_adap->notifier = NULL; 222 + n->cec_adap = NULL; 221 223 mutex_unlock(&n->lock); 222 224 cec_notifier_put(n); 223 225 }