Skip to content

Commit 42bcaac

Browse files
Hans Verkuilmchehab
authored andcommitted
media: cec: cec-api: add locking in cec_release()
When cec_release() uses fh->msgs it has to take fh->lock, otherwise the list can get corrupted. Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Reported-by: Yang, Chenyuan <cy54@illinois.edu> Closes: https://lore.kernel.org/linux-media/PH7PR11MB57688E64ADE4FE82E658D86DA09EA@PH7PR11MB5768.namprd11.prod.outlook.com/ Fixes: ca68438 ("[media] cec: add HDMI CEC framework (api)") Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
1 parent 9fe2816 commit 42bcaac

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

drivers/media/cec/core/cec-api.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -664,6 +664,8 @@ static int cec_release(struct inode *inode, struct file *filp)
664664
list_del_init(&data->xfer_list);
665665
}
666666
mutex_unlock(&adap->lock);
667+
668+
mutex_lock(&fh->lock);
667669
while (!list_empty(&fh->msgs)) {
668670
struct cec_msg_entry *entry =
669671
list_first_entry(&fh->msgs, struct cec_msg_entry, list);
@@ -681,6 +683,7 @@ static int cec_release(struct inode *inode, struct file *filp)
681683
kfree(entry);
682684
}
683685
}
686+
mutex_unlock(&fh->lock);
684687
kfree(fh);
685688

686689
cec_put_device(devnode);

0 commit comments

Comments
 (0)