Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3758885pxk; Tue, 29 Sep 2020 05:41:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxqXZSlIcJnY7NcX8x7TatKMtDggxqAntSACHWp5eIxisAyckHlVoynkPyA4aHQb45iZiaY X-Received: by 2002:a05:6402:3c8:: with SMTP id t8mr2931966edw.266.1601383305056; Tue, 29 Sep 2020 05:41:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601383305; cv=none; d=google.com; s=arc-20160816; b=IiembVuOADp1F0T49BxnAbGScqDiM3yjIsXzP0mbRw4CfD0G9P1Yy+kwCpMpnXN26u QiEkmvUjIQw9tq8YqXry5WfkodRG8DKpIq97kplvh+2m2CowCh6lNj7S0o2VWEzd/gAZ i+hWdxTEnAAVAECy7Kk/Wn9CcgOrOlDlJyHsHD5YPkm5JjsWJU35YsLjRJVK34zs0qjm w6ZOmLMdKsFKFIinGDMoCaX784Vfo3t7BHS0UAFH9xPdwm1zp3AYsWjXmLxuyXwsehWQ AJsmQ0mgacPSbPsONZKucy2dG05/Y4Bhqt2M1yWbR2Nh0Co0UGPGNga0whheaO4VeR9t qM3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CkOfp+nEpyDrqqgvP3BC4iFmkxvjkmujOYu0nUATOd8=; b=OcYWPzKX8m5+sSvqtXuZ7cTKKpqHPlcYJFqBsptoKTPzS9cYQ/wojY1wJYQNa9MbtC iYTC/S8wjeH0d4CduFaM45vv96euqF5g2vmea4AR/EYhr5gYDv9EsGvzSUpdUM1tU7P7 tYRWyTNg5WLTawxslkjvjK0zMIaQ2ZfM9ip0omEYZMSzT1hr6mbhy7qIjoY1a4MiFSkI vfM/TZkGtyVOprvFNKBHLh7FKWt1EBYa2+84GmV/C3Du6X+tgO44HVfec4mw4cRPrFyg g0ktUBxwwA0pi7zBa1bVD20J+CjHXXAGfzLYqwkfGnZfPn1+wZPHUjAHs6EHH94Ljq1W vu8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wfmtnCOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o26si1367519ejh.287.2020.09.29.05.41.22; Tue, 29 Sep 2020 05:41:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=wfmtnCOP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729466AbgI2LOs (ORCPT + 99 others); Tue, 29 Sep 2020 07:14:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:57146 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729410AbgI2LOT (ORCPT ); Tue, 29 Sep 2020 07:14:19 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 2A2AF208FE; Tue, 29 Sep 2020 11:14:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1601378057; bh=HcjsIQJ2wG7xbyWwQkeT9I6skDkr2DsBikFXcv6uPFw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfmtnCOPOUc80o5eh8RJyL3SdVW9bJHkc8NXSe0iWZA0BaaxYyHh/3cDij1WZFECV TuiYRv3uyEZQd/6CVf2fBZyrFxZ/PqF3NrPn2Vz+cBRr5P+SsvOKhWVep4+9Bzp+Vd hyl9oY1eTm9EQRAjbRpf6EZygwy2BnZsg28U7axU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nikhil Devshatwar , Benoit Parrot , Hans Verkuil , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 4.14 046/166] media: ti-vpe: cal: Restrict DMA to avoid memory corruption Date: Tue, 29 Sep 2020 12:59:18 +0200 Message-Id: <20200929105937.503880775@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200929105935.184737111@linuxfoundation.org> References: <20200929105935.184737111@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nikhil Devshatwar [ Upstream commit 6e72eab2e7b7a157d554b8f9faed7676047be7c1 ] When setting DMA for video capture from CSI channel, if the DMA size is not given, it ends up writing as much data as sent by the camera. This may lead to overwriting the buffers causing memory corruption. Observed green lines on the default framebuffer. Restrict the DMA to maximum height as specified in the S_FMT ioctl. Signed-off-by: Nikhil Devshatwar Signed-off-by: Benoit Parrot Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/ti-vpe/cal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c index b6dcae1ecc1be..ad344e642ddb7 100644 --- a/drivers/media/platform/ti-vpe/cal.c +++ b/drivers/media/platform/ti-vpe/cal.c @@ -687,12 +687,13 @@ static void pix_proc_config(struct cal_ctx *ctx) } static void cal_wr_dma_config(struct cal_ctx *ctx, - unsigned int width) + unsigned int width, unsigned int height) { u32 val; val = reg_read(ctx->dev, CAL_WR_DMA_CTRL(ctx->csi2_port)); set_field(&val, ctx->csi2_port, CAL_WR_DMA_CTRL_CPORT_MASK); + set_field(&val, height, CAL_WR_DMA_CTRL_YSIZE_MASK); set_field(&val, CAL_WR_DMA_CTRL_DTAG_PIX_DAT, CAL_WR_DMA_CTRL_DTAG_MASK); set_field(&val, CAL_WR_DMA_CTRL_MODE_CONST, @@ -1318,7 +1319,8 @@ static int cal_start_streaming(struct vb2_queue *vq, unsigned int count) csi2_lane_config(ctx); csi2_ctx_config(ctx); pix_proc_config(ctx); - cal_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline); + cal_wr_dma_config(ctx, ctx->v_fmt.fmt.pix.bytesperline, + ctx->v_fmt.fmt.pix.height); cal_wr_dma_addr(ctx, addr); csi2_ppi_enable(ctx); -- 2.25.1