From 1deb3db644326d16f7bbeb8f8ef4b7be8780fdb5 Mon Sep 17 00:00:00 2001 From: Cho KyongHo Date: Tue, 29 Sep 2015 20:42:47 +0900 Subject: [PATCH] [COMMON] media: smfc: fix bugs reported by Coverity This patch includes the fixes for CID 187514, CID187540 and 187531. Change-Id: I225fa93071e0e57f1e58825961d74cd6b315578e Signed-off-by: Cho KyongHo --- drivers/media/platform/exynos/smfc/smfc-regs.c | 4 ++-- drivers/media/platform/exynos/smfc/smfc-stream-parser.c | 8 ++++---- drivers/media/platform/exynos/smfc/smfc.h | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/exynos/smfc/smfc-regs.c b/drivers/media/platform/exynos/smfc/smfc-regs.c index e4bcba78a88c..d88a4d5514e8 100644 --- a/drivers/media/platform/exynos/smfc/smfc-regs.c +++ b/drivers/media/platform/exynos/smfc/smfc-regs.c @@ -437,7 +437,7 @@ bool smfc_hwstatus_okay(struct smfc_dev *smfc, struct smfc_ctx *ctx) __raw_writel(reg, smfc->reg + REG_MAIN_JPEG_CNTL); val = __raw_readl(smfc->reg + REG_MAIN_INT_STATUS); - if (smfc_is_capable(ctx->smfc, V4L2_CAP_EXYNOS_JPEG_B2B_COMPRESSION)) + if (smfc_is_capable(smfc, V4L2_CAP_EXYNOS_JPEG_B2B_COMPRESSION)) val2 = __raw_readl(smfc->reg + REG_SEC_INT_STATUS); if (!val && !val2) { @@ -455,7 +455,7 @@ bool smfc_hwstatus_okay(struct smfc_dev *smfc, struct smfc_ctx *ctx) return false; } - if (!!(ctx->flags & SMFC_CTX_B2B_COMPRESS) && !val2) { + if (ctx && !!(ctx->flags & SMFC_CTX_B2B_COMPRESS) && !val2) { dev_err(smfc->dev, "Secondary image is not completed\n"); return false; } diff --git a/drivers/media/platform/exynos/smfc/smfc-stream-parser.c b/drivers/media/platform/exynos/smfc/smfc-stream-parser.c index 951056e73452..528e31a3ba31 100644 --- a/drivers/media/platform/exynos/smfc/smfc-stream-parser.c +++ b/drivers/media/platform/exynos/smfc/smfc-stream-parser.c @@ -20,6 +20,8 @@ static bool smfc_alloc_tables(struct smfc_ctx *ctx) { + int i; + if (!ctx->quantizer_tables) { ctx->quantizer_tables = kmalloc( sizeof(*ctx->quantizer_tables), GFP_KERNEL); @@ -27,10 +29,8 @@ static bool smfc_alloc_tables(struct smfc_ctx *ctx) return false; } memset(ctx->quantizer_tables, 0, sizeof(*ctx->quantizer_tables)); - ctx->quantizer_tables->compsel[0] = INVALID_QTBLIDX; - ctx->quantizer_tables->compsel[1] = INVALID_QTBLIDX; - ctx->quantizer_tables->compsel[2] = INVALID_QTBLIDX; - ctx->quantizer_tables->compsel[3] = INVALID_QTBLIDX; + for (i = 0; i < SMFC_MAX_QTBL_COUNT; i++) + ctx->quantizer_tables->compsel[i] = INVALID_QTBLIDX; if (!ctx->huffman_tables) { ctx->huffman_tables = kmalloc( diff --git a/drivers/media/platform/exynos/smfc/smfc.h b/drivers/media/platform/exynos/smfc/smfc.h index 1b02196bdf55..222f53ff3ab3 100644 --- a/drivers/media/platform/exynos/smfc/smfc.h +++ b/drivers/media/platform/exynos/smfc/smfc.h @@ -148,7 +148,7 @@ struct smfc_decomp_htable { struct smfc_decomp_qtable { /* quantizers are *NOT* stored in the zig-zag scan order */ u8 table[SMFC_MAX_QTBL_COUNT][SMFC_MCU_SIZE]; - char compsel[SMFC_MAX_NUM_COMP]; /* compsel[0] for component 1 */ + char compsel[SMFC_MAX_QTBL_COUNT]; }; struct smfc_ctx { -- 2.20.1