]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: platform: allegro-dvt: Fix possible memory leak in allocate_buffers_internal()
authorGaosheng Cui <cuigaosheng1@huawei.com>
Wed, 9 Oct 2024 08:28:02 +0000 (16:28 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 14 Dec 2024 18:47:36 +0000 (19:47 +0100)
commit 0f514068fbc5d4d189c817adc7c4e32cffdc2e47 upstream.

The buffer in the loop should be released under the exception path,
otherwise there may be a memory leak here.

To mitigate this, free the buffer when allegro_alloc_buffer fails.

Fixes: f20387dfd065 ("media: allegro: add Allegro DVT video IP core driver")
Cc: <stable@vger.kernel.org>
Signed-off-by: Gaosheng Cui <cuigaosheng1@huawei.com>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/media/allegro-dvt/allegro-core.c

index 28b6ba895ccd5663c5547fcb7d2f557b1065136a..84bd3d8649a89a4f3f955cbbff6f47a51ee3bff0 100644 (file)
@@ -1208,8 +1208,10 @@ static int allocate_buffers_internal(struct allegro_channel *channel,
                INIT_LIST_HEAD(&buffer->head);
 
                err = allegro_alloc_buffer(dev, buffer, size);
-               if (err)
+               if (err) {
+                       kfree(buffer);
                        goto err;
+               }
                list_add(&buffer->head, list);
        }