Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp1120142pxa; Fri, 28 Aug 2020 04:26:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyQ8Qe6nl2sbegEmCFzLiPJOkKQD60y55QFujl5h6ha/Ot7NawPdGs4XcnLFrtzx0bEvjmz X-Received: by 2002:a17:906:8688:: with SMTP id g8mr1239856ejx.25.1598613980228; Fri, 28 Aug 2020 04:26:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598613980; cv=none; d=google.com; s=arc-20160816; b=WXm4YnxlpY6wYVtrwFVLnoj6eF6iWio+FjH4Xvo1+zaF3h78YhvclcwwIGTeL76W2C iSno45HJjovQjtC1eGPwpvCkc5LNxJLTM8U5tpt2/+pB/18ccANw6jRHMVPQXrWTmhR9 /vaIaFR2xTHWQqFdjmxsNtNswvcNuop9QJLFXxdaH2ju1YdxaObds3Q1yf9heuD9gDys KdZ0DsVucS9LlkUkBUXlzWZEV3q/RGBlFEmXpOb8Kj8gEIiI8mW2rezxStpvkL8F6nWs fwNr1RyhdtHVEj6Y0qUm2JGWy1IGEuvqRoIRDX0kigFbECy4mxXRWiLac5v4c1j1RGZZ Gurg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2b9BNpV1Lr52/Li226uRkHLAadPLNrWC+ed48GuloA0=; b=GpCkaX+JeDfkqbaujY0D82nwgJu9bkijksRaMI+8JocJfUznGExgVxiBDRtfXGlcni LGSouabbwt29ryoIZaXXK41M7WTuiPxzjAGawsbkrGcHPjx8sOtDAVoXhr3Ic+r+gS6H /169mmwYUcQ2B/q/pbC4gEhiOxctscGTEqu9wfh1hvERwvl08Y8+2pFBHZKLjtu7w8DT VErKxsvX53ZfOulLES80fpIGQqAVmVfxIgZ57NgrAMD05sFWp4UDjrW4aOk6VOjG/f9o nzhV4CASyQRUbXekukDLKKeBOgMlv/1xWxq/PAGPZklGn1+wLKxXwKA7I5uvHqKGjCJq /f1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@megous.com header.s=mail header.b=T0Lb7AqU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si421570ejd.406.2020.08.28.04.25.56; Fri, 28 Aug 2020 04:26:20 -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=@megous.com header.s=mail header.b=T0Lb7AqU; 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=pass (p=NONE sp=NONE dis=NONE) header.from=megous.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729198AbgH1LZI (ORCPT + 99 others); Fri, 28 Aug 2020 07:25:08 -0400 Received: from vps.xff.cz ([195.181.215.36]:37914 "EHLO vps.xff.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728936AbgH1LY7 (ORCPT ); Fri, 28 Aug 2020 07:24:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1598613887; bh=v6vwqjlQVjAwBtNJBEWlutEj4KTBBjU4D4rsUlgzXqE=; h=From:To:Cc:Subject:Date:From; b=T0Lb7AqUQwuKpKxGUr18AG0ZbMbTYK5V5hNDxOWWpo3BCtI2rtPdfvsI2KF8A4DBB +SYE8pEkXBeiqn026A1KgfZgKl68yaf2PXHHozlgl7SJXflps3OpkWcV/39i/Q6g6u ywrIox9b2qCqrvR0ikmW0sNmLTxvQcK728IjaT88= From: Ondrej Jirman To: linux-sunxi@googlegroups.com Cc: Ondrej Jirman , Maxime Ripard , Chen-Yu Tsai , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org (open list:DRM DRIVERS FOR ALLWINNER A10), linux-arm-kernel@lists.infradead.org (moderated list:ARM/Allwinner sunXi SoC support), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] drm/sun4i: Fix dsi dcs long write function Date: Fri, 28 Aug 2020 13:24:44 +0200 Message-Id: <20200828112444.916455-1-megous@megous.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's writing too much data. regmap_bulk_write expects number of register sized chunks to write, not a byte sized length of the bounce buffer. Bounce buffer needs to be padded too, so that regmap_bulk_write will not read past the end of the buffer. Signed-off-by: Ondrej Jirman --- drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c index 7f13f4d715bf..840fad1b68dd 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -889,7 +889,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi, regmap_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(0), sun6i_dsi_dcs_build_pkt_hdr(dsi, msg)); - bounce = kzalloc(msg->tx_len + sizeof(crc), GFP_KERNEL); + bounce = kzalloc(msg->tx_len + sizeof(crc) + 3, GFP_KERNEL); if (!bounce) return -ENOMEM; @@ -900,7 +900,7 @@ static int sun6i_dsi_dcs_write_long(struct sun6i_dsi *dsi, memcpy((u8 *)bounce + msg->tx_len, &crc, sizeof(crc)); len += sizeof(crc); - regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, len); + regmap_bulk_write(dsi->regs, SUN6I_DSI_CMD_TX_REG(1), bounce, DIV_ROUND_UP(len, 4)); regmap_write(dsi->regs, SUN6I_DSI_CMD_CTL_REG, len + 4 - 1); kfree(bounce); -- 2.28.0