summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil-cisco@xs4all.nl>2019-08-23 08:12:59 -0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 13:09:49 +0200
commitab20f38ce52212298cc151bb2a835ce4092f5a6a (patch)
tree3ace27e603b4f6a498f45db1506c34525037dfe1 /drivers/media
parentd51268d7574b14f67fe7ff51b193a9bb594535e2 (diff)
downloadlinux-stable-ab20f38ce52212298cc151bb2a835ce4092f5a6a.tar.gz
linux-stable-ab20f38ce52212298cc151bb2a835ce4092f5a6a.tar.bz2
linux-stable-ab20f38ce52212298cc151bb2a835ce4092f5a6a.zip
media: cec-notifier: clear cec_adap in cec_notifier_unregister
[ Upstream commit 14d5511691e5290103bc480998bc322e68f139d4 ] 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> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/cec/cec-notifier.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/drivers/media/cec/cec-notifier.c b/drivers/media/cec/cec-notifier.c
index dd2078b27a41..2424680f71c3 100644
--- a/drivers/media/cec/cec-notifier.c
+++ b/drivers/media/cec/cec-notifier.c
@@ -123,6 +123,8 @@ void cec_notifier_unregister(struct cec_notifier *n)
{
mutex_lock(&n->lock);
n->callback = NULL;
+ n->cec_adap->notifier = NULL;
+ n->cec_adap = NULL;
mutex_unlock(&n->lock);
cec_notifier_put(n);
}