From patchwork Tue Mar 26 07:44:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Courbot X-Patchwork-Id: 10870573 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5F6B915AC for ; Tue, 26 Mar 2019 07:44:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 485F128D96 for ; Tue, 26 Mar 2019 07:44:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BB6728DBD; Tue, 26 Mar 2019 07:44:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C4A5B28D9B for ; Tue, 26 Mar 2019 07:44:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=pDrK41WQFbb9YhhlTo0hG9Rd4sfqNHfdp+IK1ZVr9ZE=; b=ftAh+uzC+yRjto hvd2zlluv3xYIcvPnGOEbevLE+bli7z4Kv/liAEije9E9KDg6cqCUaFfWyw4uoRIjpTMTCcxFQiBy SsTcaXneMsOBusN2KvOIhMvmTFfVJMcdXhHm8sKj+kDEzIy1IgpvB0qvfNoQ1A8pP/9tL7qK84FyW LIfeBed2qRo9zaK558HG1WJYYInkUfCeQd22dUmDscXG6Hgv61JBEwOhVQWENMKQAFg3hxpplQEnl u7UVFzQtuLiFpyO+BACyPKPPHNQDTNKkscEx6rbq3QfBQiPj4nlr/foMRcsSR9iEPHYrx3tJ2IR3E VZb4RSOUU+ewGYj6sS3A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8glF-0007QC-SD; Tue, 26 Mar 2019 07:44:41 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1h8gl9-0007PM-DA for linux-mediatek@lists.infradead.org; Tue, 26 Mar 2019 07:44:39 +0000 Received: by mail-pf1-x444.google.com with SMTP id 8so7698463pfr.4 for ; Tue, 26 Mar 2019 00:44:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=guX9JjzludzjpfbhyDia6d8Kx5PRCAeJ16z/HP1EEq8=; b=Z6v0XXqM7DONOBaYbfDIEbQF39dWcHODW3NiueK5leRqOl31GAH3JjWOtt5LUV58Wn SEksRJkRoXrHkTuur7PzDZekWyCXNpjPgMtaInVdGo+1XuXVBtSMezQfxsEUasvUC8yW pb0w+3/lBkkJvXQqJ0Mfb7e47wM46xol6Qo6I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=guX9JjzludzjpfbhyDia6d8Kx5PRCAeJ16z/HP1EEq8=; b=qfmbefdbN9aqnmh52G76KDHbfRWIOpzdxi1tv/ImqXFbcewuSmC8n1HW89ygpHkets x/gAmiCCvt7c8exgADcKc4qjpEnA9wP0zqNyvLhljKuxqniITBxC8NrrMtNTKYAbOV+U RCEiYWJmpcN9n29lRfCJWxcQSk5Kjsx75BfCr/DrWP1VY8UPUBZedyMy5zeGMb2IifOL a0PQJyG1e5Dc3OPebgb3f25mXD2C2JfkqoW11r4yLT7zbnO7k/2GuveIBCZGUvzlWiZv 7F4BZV7qo22oCOjtY1/Vzwt9P55PDJipOiorHH8lA6/iJPRvYqBsFW2RVK6RHAohCVL9 zW6Q== X-Gm-Message-State: APjAAAWFuf0eW4snD5+WQ8f+NeGqxlwgHix4DQHKM7TfiN3T/oWbGZUC AwrVquF4sd1dQz5lgYrkJ6/pSw== X-Google-Smtp-Source: APXvYqyaJId/+xlnGKhyV500nOy9o4V1J2JSBRH2FN7nRJEBNWH3MDDTL/+Rtka8ilCknE+BJPh64w== X-Received: by 2002:a62:e502:: with SMTP id n2mr28662586pff.242.1553586272232; Tue, 26 Mar 2019 00:44:32 -0700 (PDT) Received: from acourbot.tok.corp.google.com ([2401:fa00:4:4:9712:8cf1:d0f:7d33]) by smtp.gmail.com with ESMTPSA id n9sm19716753pff.43.2019.03.26.00.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Mar 2019 00:44:31 -0700 (PDT) From: Alexandre Courbot To: Ezequiel Garcia , Tiffany Lin , Andrew-CT Chen , Mauro Carvalho Chehab Subject: [PATCH] media: mtk-vcodec: fix access to incorrect planes member Date: Tue, 26 Mar 2019 16:44:23 +0900 Message-Id: <20190326074423.123864-1-acourbot@chromium.org> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190326_004435_469780_A023517D X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, Alexandre Courbot , linux-media@vger.kernel.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Commit 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") fixed the return types for mem2mem buffer helper functions by changing a few local variables from vb2_buffer to vb2_v4l2_buffer. However, it left a few accesses to vb2_buffer::planes as-is, accidentally turning them into accesses to vb2_v4l2_buffer::planes and resulting in values being read from/written to the wrong place. Fix this by inserting vb2_buf into these accesses so they mimic their original behavior. Fixes: 0650a91499e0 ("media: mtk-vcodec: Correct return type for mem2mem buffer helpers") Signed-off-by: Alexandre Courbot Reviewed-by: Ezequiel Garcia --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++-- drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index a85c7cc8328e..e20b340855e7 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -388,7 +388,7 @@ static void mtk_vdec_worker(struct work_struct *work) } buf.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0); buf.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0); - buf.size = (size_t)src_buf->planes[0].bytesused; + buf.size = (size_t)src_buf->vb2_buf.planes[0].bytesused; if (!buf.va) { v4l2_m2m_job_finish(dev->m2m_dev_dec, ctx->m2m_ctx); mtk_v4l2_err("[%d] id=%d src_addr is NULL!!", @@ -1155,7 +1155,7 @@ static void vb2ops_vdec_buf_queue(struct vb2_buffer *vb) src_mem.va = vb2_plane_vaddr(&src_buf->vb2_buf, 0); src_mem.dma_addr = vb2_dma_contig_plane_dma_addr(&src_buf->vb2_buf, 0); - src_mem.size = (size_t)src_buf->planes[0].bytesused; + src_mem.size = (size_t)src_buf->vb2_buf.planes[0].bytesused; mtk_v4l2_debug(2, "[%d] buf id=%d va=%p dma=%pad size=%zx", ctx->id, src_buf->vb2_buf.index, diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c index c6b48b5925fb..50351adafc47 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_enc.c @@ -894,7 +894,7 @@ static void vb2ops_venc_stop_streaming(struct vb2_queue *q) if (q->type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) { while ((dst_buf = v4l2_m2m_dst_buf_remove(ctx->m2m_ctx))) { - dst_buf->planes[0].bytesused = 0; + dst_buf->vb2_buf.planes[0].bytesused = 0; v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR); } } else { @@ -947,7 +947,7 @@ static int mtk_venc_encode_header(void *priv) bs_buf.va = vb2_plane_vaddr(&dst_buf->vb2_buf, 0); bs_buf.dma_addr = vb2_dma_contig_plane_dma_addr(&dst_buf->vb2_buf, 0); - bs_buf.size = (size_t)dst_buf->planes[0].length; + bs_buf.size = (size_t)dst_buf->vb2_buf.planes[0].length; mtk_v4l2_debug(1, "[%d] buf id=%d va=0x%p dma_addr=0x%llx size=%zu", @@ -976,7 +976,7 @@ static int mtk_venc_encode_header(void *priv) } ctx->state = MTK_STATE_HEADER; - dst_buf->planes[0].bytesused = enc_result.bs_size; + dst_buf->vb2_buf.planes[0].bytesused = enc_result.bs_size; v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE); return 0; @@ -1107,12 +1107,12 @@ static void mtk_venc_worker(struct work_struct *work) if (ret) { v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_ERROR); - dst_buf->planes[0].bytesused = 0; + dst_buf->vb2_buf.planes[0].bytesused = 0; v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_ERROR); mtk_v4l2_err("venc_if_encode failed=%d", ret); } else { v4l2_m2m_buf_done(src_buf, VB2_BUF_STATE_DONE); - dst_buf->planes[0].bytesused = enc_result.bs_size; + dst_buf->vb2_buf.planes[0].bytesused = enc_result.bs_size; v4l2_m2m_buf_done(dst_buf, VB2_BUF_STATE_DONE); mtk_v4l2_debug(2, "venc_if_encode bs size=%d", enc_result.bs_size);