This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: allegro: Fix use after free on error
Author:  Dan Carpenter <[email protected]>
Date:    Mon Dec 14 12:54:47 2020 +0100

The "channel" is added to the "dev->channels" but then if
v4l2_m2m_ctx_init() fails then we free "channel" but it's still on the
list so it could lead to a use after free.  Let's not add it to the
list until after v4l2_m2m_ctx_init() succeeds.

Fixes: cc62c74749a3 ("media: allegro: add missed checks in allegro_open()")
Signed-off-by: Dan Carpenter <[email protected]>
Reviewed-by: Michael Tretter <[email protected]>
Signed-off-by: Hans Verkuil <[email protected]>
Signed-off-by: Mauro Carvalho Chehab <[email protected]>

 drivers/staging/media/allegro-dvt/allegro-core.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

---

diff --git a/drivers/staging/media/allegro-dvt/allegro-core.c 
b/drivers/staging/media/allegro-dvt/allegro-core.c
index 9f718f43282b..640451134072 100644
--- a/drivers/staging/media/allegro-dvt/allegro-core.c
+++ b/drivers/staging/media/allegro-dvt/allegro-core.c
@@ -2483,8 +2483,6 @@ static int allegro_open(struct file *file)
        INIT_LIST_HEAD(&channel->buffers_reference);
        INIT_LIST_HEAD(&channel->buffers_intermediate);
 
-       list_add(&channel->list, &dev->channels);
-
        channel->fh.m2m_ctx = v4l2_m2m_ctx_init(dev->m2m_dev, channel,
                                                allegro_queue_init);
 
@@ -2493,6 +2491,7 @@ static int allegro_open(struct file *file)
                goto error;
        }
 
+       list_add(&channel->list, &dev->channels);
        file->private_data = &channel->fh;
        v4l2_fh_add(&channel->fh);
 

_______________________________________________
linuxtv-commits mailing list
[email protected]
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to