]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
media: coda: Add check for dcoda_iram_alloc
authorJiasheng Jiang <jiasheng@iscas.ac.cn>
Thu, 17 Nov 2022 06:56:52 +0000 (14:56 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 7 Jan 2023 11:07:20 +0000 (12:07 +0100)
[ Upstream commit 6b8082238fb8bb20f67e46388123e67a5bbc558d ]

As the coda_iram_alloc may return NULL pointer,
it should be better to check the return value
in order to avoid NULL poineter dereference,
same as the others.

Fixes: b313bcc9a467 ("[media] coda: simplify IRAM setup")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/media/platform/coda/coda-bit.c

index 7b4c93619c3d5bd7d571f3fd0db81c50e390cdb7..b62c7098fc8cc734662a499490cef9fb961bbfcc 100644 (file)
@@ -595,7 +595,7 @@ static void coda_setup_iram(struct coda_ctx *ctx)
                /* Only H.264BP and H.263P3 are considered */
                iram_info->buf_dbk_y_use = coda_iram_alloc(iram_info, w64);
                iram_info->buf_dbk_c_use = coda_iram_alloc(iram_info, w64);
-               if (!iram_info->buf_dbk_c_use)
+               if (!iram_info->buf_dbk_y_use || !iram_info->buf_dbk_c_use)
                        goto out;
                iram_info->axi_sram_use |= dbk_bits;
 
@@ -619,7 +619,7 @@ static void coda_setup_iram(struct coda_ctx *ctx)
 
                iram_info->buf_dbk_y_use = coda_iram_alloc(iram_info, w128);
                iram_info->buf_dbk_c_use = coda_iram_alloc(iram_info, w128);
-               if (!iram_info->buf_dbk_c_use)
+               if (!iram_info->buf_dbk_y_use || !iram_info->buf_dbk_c_use)
                        goto out;
                iram_info->axi_sram_use |= dbk_bits;