From patchwork Fri Aug 28 12:50:32 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ond=C5=99ej_Jirman?= X-Patchwork-Id: 11742729 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A62311575 for ; Fri, 28 Aug 2020 12:50:51 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7F82A2086A for ; Fri, 28 Aug 2020 12:50:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="fxsZy5w0"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=megous.com header.i=@megous.com header.b="b07fnjeN" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7F82A2086A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=megous.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.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=GDCfQAtOjSL5P2maci1AdisReUp1NWi5aD12i2Xqrxc=; b=fxsZy5w0sODZ4hEcsPQU0vWLnI uPIEGOfRFkosOEcHJ8NJ9EOsbYkzmplH9R5EW+Qhl1tWRzr8q3b2XGIKg75kl1IC2z2pQVmilNQ9a yEp5pM94bbJTw+MyS52FRMt5x1zFq53jhgFSMSN/09S3JIvrSP7X59xnsYEzwhfzSmM5+eRk66AZz IgBurcRQJKt7Bk9gktmqcloE9u0Kcs3tInI1DNKFBU3FGr2VMYAtFCsRlq6ohacQYRiuTu3q8irF2 C6p5iq50rK44XC91XLyH0uEHGatO2WQHY3MeDYgHF2XRnR+Tr8Ie6OdtrH6N4xbaozUK9A3p/NP1H J9Jt1OTQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBdq2-0007J2-V7; Fri, 28 Aug 2020 12:50:38 +0000 Received: from vps.xff.cz ([195.181.215.36]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kBdpz-0007Hq-K3 for linux-arm-kernel@lists.infradead.org; Fri, 28 Aug 2020 12:50:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=megous.com; s=mail; t=1598619033; bh=nxUWIm3gy/O9YpC9oWvFu3EIfP25ydy4pKjYKk0i/qE=; h=From:To:Cc:Subject:Date:From; b=b07fnjeNJJsvJjL2xaCzpKxNgztTc6dQlBOhVGsdxfEyWuR3tjCZpH/5LJlddl2p7 Nu85p4YCWwFtH8FWhC+laJZN3XaDcSd4zSEuGPiXjut5p9lMGHNV41dXa6NoXnhje5 7ADi4CdrKSp+gncwYxJ65IjZs325UpgVm9FzhEcA= From: Ondrej Jirman To: linux-sunxi@googlegroups.com Subject: [PATCH v2] drm/sun4i: Fix dsi dcs long write function Date: Fri, 28 Aug 2020 14:50:32 +0200 Message-Id: <20200828125032.937148-1-megous@megous.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200828_085035_801469_6BFB2E25 X-CRM114-Status: GOOD ( 10.83 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ondrej Jirman , Jernej Skrabec , David Airlie , open list , Maxime Ripard , Chen-Yu Tsai , "open list:DRM DRIVERS FOR ALLWINNER A10" , Daniel Vetter , "moderated list:ARM/Allwinner sunXi SoC support" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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. Fixes: 133add5b5ad4 ("drm/sun4i: Add Allwinner A31 MIPI-DSI controller support") Signed-off-by: Ondrej Jirman Reviewed-by: Jernej Skrabec --- v2: - use ALIGN - add tags 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(ALIGN(msg->tx_len + sizeof(crc), 4), 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);