media: atomisp: Fix use after free in atomisp_alloc_css_stat_bufs()
authorDan Carpenter <dan.carpenter@oracle.com>
Mon, 14 Dec 2020 11:53:31 +0000 (12:53 +0100)
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Mon, 22 Mar 2021 22:28:09 +0000 (23:28 +0100)
The "s3a_buf" is freed along with all the other items on the
"asd->s3a_stats" list.  It leads to a double free and a use after free.

Link: https://lore.kernel.org/linux-media/X9dSO3RGf7r0pq2k@mwanda
Fixes: ad85094b293e ("Revert "media: staging: atomisp: Remove driver"")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
drivers/staging/media/atomisp/pci/atomisp_ioctl.c

index de398c791f28dc56f557df46f89f0f2c8538fc44..548d82028bb09e027cb984192ee7a371cc8c1f82 100644 (file)
@@ -948,10 +948,8 @@ int atomisp_alloc_css_stat_bufs(struct atomisp_sub_device *asd,
                dev_dbg(isp->dev, "allocating %d dis buffers\n", count);
                while (count--) {
                        dis_buf = kzalloc(sizeof(struct atomisp_dis_buf), GFP_KERNEL);
-                       if (!dis_buf) {
-                               kfree(s3a_buf);
+                       if (!dis_buf)
                                goto error;
-                       }
                        if (atomisp_css_allocate_stat_buffers(
                                asd, stream_id, NULL, dis_buf, NULL)) {
                                kfree(dis_buf);