From patchwork Thu Nov 10 05:24:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wu-Cheng Li X-Patchwork-Id: 9420651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 687776048E for ; Thu, 10 Nov 2016 05:26:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 586F128F52 for ; Thu, 10 Nov 2016 05:26:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4D2FD28F87; Thu, 10 Nov 2016 05:26:39 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 1C35D28F52 for ; Thu, 10 Nov 2016 05:26:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4hrL-00050j-NU; Thu, 10 Nov 2016 05:25:11 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1c4hr1-0004T3-EC for linux-arm-kernel@lists.infradead.org; Thu, 10 Nov 2016 05:24:52 +0000 Received: by mail-pf0-x234.google.com with SMTP id i88so139058594pfk.2 for ; Wed, 09 Nov 2016 21:24:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=/OeWjoTQ0tO4XCq1vAFV8oJYsqQU4iXms1fnDjTAmWA=; b=IfV8ClkLm/4HKHPGj4l0Rm48Sp3hM3OB572sNe/DtLD7bGEhi7q5ihQDrXSSvD0Jlv 6B/CR3g6/gUWKJJOxWILIrD9cJJ6ipy1iduocpUa3SP+jpgdgC8j+T1QnFrYkK0KWM3J bX685R9dpjGbDsgqhcBJ0oY5Nq8tUOqC91AmA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=/OeWjoTQ0tO4XCq1vAFV8oJYsqQU4iXms1fnDjTAmWA=; b=MftyKmg5cXrtYgcxooWn4LJ/tcS5QdEpn7j1LW7pa5nZnK8pTztXfIluaheEG8hG1j Jh5GRcp45kfUG8nVNhc65VURkt/QPgcUG1n99+WTtmjJaWmCUyTnhsvi8ApNE8WKhUVZ 9dC9htL3kZiXU+RcwdwGtm2DdfV7395SZPsoklGlZdX38ZgDfEUerbJ3qbTwk9Zl2CiT SPGAduEj2IUnXL5d0/2mJOAnZkQiDncJ481uhCIr0BwNBeMmEkeclvvqslFgNf+qfcoy LOAzITz0go5ONUOL9duG0tOnm2+XuwDUIShNgjKW1HqgA/rTe2nIbKknxhYcKEAZM3CQ N6Ug== X-Gm-Message-State: ABUngves/pfFWWNHKrrYl9Aoi2Nn0ZDumtMUg82Oarp5fLYY0wShHY49IhY2qEzqP3ioeIpM X-Received: by 10.98.208.70 with SMTP id p67mr6505927pfg.15.1478755469875; Wed, 09 Nov 2016 21:24:29 -0800 (PST) Received: from wuchengli-z840.tpe.corp.google.com ([172.30.210.26]) by smtp.gmail.com with ESMTPSA id 3sm3216403pam.21.2016.11.09.21.24.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 09 Nov 2016 21:24:29 -0800 (PST) From: Wu-Cheng Li To: pawel@osciak.com, tiffany.lin@mediatek.com, andrew-ct.chen@mediatek.com, mchehab@kernel.org, matthias.bgg@gmail.com, djkurtz@chromium.org, dan.carpenter@oracle.com Subject: [PATCH v1] mtk-vcodec: add index check in decoder vidioc_qbuf. Date: Thu, 10 Nov 2016 13:24:05 +0800 Message-Id: <1478755445-23494-2-git-send-email-wuchengli@chromium.org> X-Mailer: git-send-email 2.8.0.rc3.226.g39d4020 In-Reply-To: <1478755445-23494-1-git-send-email-wuchengli@chromium.org> References: <1478755445-23494-1-git-send-email-wuchengli@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161109_212451_652619_B70C4DF5 X-CRM114-Status: GOOD ( 10.39 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wu-Cheng Li , linux-kernel@vger.kernel.org, Wu-Cheng Li , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Wu-Cheng Li vb2_qbuf will check the buffer index. If a driver overrides vidioc_qbuf and use the buffer index, the driver needs to check the index. Signed-off-by: Wu-Cheng Li --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c index 0520919..0746592 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec.c @@ -533,6 +533,10 @@ static int vidioc_vdec_qbuf(struct file *file, void *priv, } vq = v4l2_m2m_get_vq(ctx->m2m_ctx, buf->type); + if (buf->index >= vq->num_buffers) { + mtk_v4l2_debug(1, "buffer index %d out of range", buf->index); + return -EINVAL; + } vb = vq->bufs[buf->index]; vb2_v4l2 = container_of(vb, struct vb2_v4l2_buffer, vb2_buf); mtkbuf = container_of(vb2_v4l2, struct mtk_video_dec_buf, vb);