[COMMON] media: smfc: fix prevent issue
authorSeungchul Kim <sc377.kim@samsung.com>
Fri, 24 Nov 2017 06:02:51 +0000 (15:02 +0900)
committerSeungchul Kim <sc377.kim@samsung.com>
Mon, 28 May 2018 05:31:23 +0000 (14:31 +0900)
This patch fixed below prevent issue about other violation types.

CID 201997, 201944, 200890, 200853

Change-Id: Icf94074d36c7d4526e13e25c9dc188875dabec77
Signed-off-by: Seungchul Kim <sc377.kim@samsung.com>
drivers/media/platform/exynos/smfc/smfc-regs.c
drivers/media/platform/exynos/smfc/smfc-stream-parser.c

index ff7a82a1ee64088dfa3c685f161ca8ba001e5c10..4ec5e1643a99acb418c6dbaabdbba7405106e366 100644 (file)
@@ -411,7 +411,7 @@ void smfc_hwconfigure_image(struct smfc_ctx *ctx,
        stream_address = smfc_hwconfigure_jpeg_base(ctx, &vb2buf_jpg->vb2_buf,
                                                    ctx->offset_of_sos, false);
        if (!(ctx->flags & SMFC_CTX_COMPRESS)) {
-               u32 streamsize = vb2_plane_size(&vb2buf_jpg->vb2_buf, 0);
+               u32 streamsize = (u32)vb2_plane_size(&vb2buf_jpg->vb2_buf, 0);
 
                streamsize -= ctx->offset_of_sos;
                streamsize += stream_address & SMFC_ADDR_ALIGN_MASK(burstlen);
index b2d09840a2a09106f6aecf7be170631f2d0b78e7..1db39b3f98db676a1c58db88420f492f66403e04 100644 (file)
@@ -155,7 +155,7 @@ static int smfc_parse_dht(struct smfc_ctx *ctx, unsigned long *cursor)
                table = dc ? ctx->huffman_tables->dc[tcth & 1].value
                           : ctx->huffman_tables->ac[tcth & 1].value;
                ret = copy_from_user(table, pcursor, num_values);
-               pcursor += num_values;
+               pcursor += (unsigned long)num_values;
                if (ret) {
                        dev_err(ctx->smfc->dev,
                                "Failed to read huffval of %d,%d\n",
@@ -205,7 +205,7 @@ static int smfc_parse_dqt(struct smfc_ctx *ctx, unsigned long *cursor)
 
                ret = copy_from_user(ctx->quantizer_tables->table[pqtq],
                                                        pcursor, SMFC_MCU_SIZE);
-               pcursor += SMFC_MCU_SIZE;
+               pcursor += (unsigned long)SMFC_MCU_SIZE;
                if (ret) {
                        dev_err(ctx->smfc->dev,
                                "Failed to read %dth Q-Table\n", pqtq);
@@ -303,7 +303,7 @@ static int smfc_parse_scanheader(struct smfc_ctx *ctx,
 
        pos = sos;
 
-       ctx->offset_of_sos = *cursor - streambase - SMFC_JPEG_MARKER_LEN;
+       ctx->offset_of_sos = (unsigned int)(*cursor - streambase - SMFC_JPEG_MARKER_LEN);
 
        ret = copy_from_user(sos, (void __user *)*cursor, sizeof(sos));
        if (ret) {