Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp24520pxk; Tue, 15 Sep 2020 16:42:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAGQU0IhBYSfoUMJUAqrRy37NbeJQoq5zapjV1E7uX3v5tBHdsTjDB3Q487O2J4X1JO302 X-Received: by 2002:a17:906:a211:: with SMTP id r17mr10585693ejy.444.1600213356244; Tue, 15 Sep 2020 16:42:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600213356; cv=none; d=google.com; s=arc-20160816; b=JFXQkRmUwfGTfEY1+vUpU2JOwsCrf+wIQLPP0X6E2tGmSNCxLLAa3bZUr27Y+KFLx/ tdQpwHbCuuUpOEMwr1ttqrQ9l5qlhZPhkeghtkQ3UNk+GfZazJ2X5IM755goAKTRGJR6 eYapPWlADxStQs9mppXTSA64hLAGw7Axz7MxWIFFu2Na/f9dS8UwIasP0B12oqiLmCeq oaRwrnujNlyfzPy28dr0AR2An6VXRb/vFQHcKKW13C5fQHEk4BVK7wEW19rl3eWnkCZZ KXHYs9kqwSUzwFrSzW9dTYDP43ruvqJ0jo2spP72P5S5RpjBmhuSI67iDzloMwDIJRrJ mj0w== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k+vo2ZAZJcWExBEWWTkmujMe82rSpk0N7lsaxIrBPDE=; b=jC2kuZwqq4n6FJnoXaT9Iw+4MYz/8mbHdBWK6fhEFeYRlPOKT1qhaN2wCtm+GIwhzP DMb3aNGTv+ZYKAlTFPqnwza3jRGObsQPbWeNs7FXZ9vwDAxhF8W7GcAOSzVnJLdv27Dj QDdLIaHkd7b48lhXSzEJ5wW4Q0mCfleC7C6JmgyZDI/LKsPzH/0RT5yn9e6ilm56vxK2 un7VnpZG98nHJa89qlubXNCWuGW6aIKa8nZuZhy0sKtStQMExDWrkd+UjNlFGVOPWjpD QvL9AB1r0B2AEF9Abaeu3E9zyF6tgJLF7k3S8aYAEgvYj/r7rVFAyFn9stBIwbP7v+sp eUfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q9+ZFo6W; 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 u23si10696362edq.185.2020.09.15.16.42.14; Tue, 15 Sep 2020 16:42:36 -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=q9+ZFo6W; 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 S1727344AbgIOXjn (ORCPT + 99 others); Tue, 15 Sep 2020 19:39:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:46174 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727071AbgIOOet (ORCPT ); Tue, 15 Sep 2020 10:34:49 -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 0B78422224; Tue, 15 Sep 2020 14:16:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600179374; bh=VMRScTNZjqcuxBSNlIcKXYNZRhstNmmeSh2GLH+N330=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q9+ZFo6WJV99XpfcW/E096RTq96cAsLvbkG1nhoQX+xGWFqVjo5u/1m4PRvF1KMAk j8dhI5TZnzCVvXRvcMvbIixwbczEDpai9jrAGA0rs4FhD4lUSeZBR5Oa3IqGmRPz04 PjLyRoG4/leU2LkB7NBizAggKi1Hp8aNVydcMtzo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ondrej Jirman , Maxime Ripard , Jernej Skrabec , Sasha Levin Subject: [PATCH 4.19 08/78] drm/sun4i: Fix dsi dcs long write function Date: Tue, 15 Sep 2020 16:12:33 +0200 Message-Id: <20200915140633.952390220@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200915140633.552502750@linuxfoundation.org> References: <20200915140633.552502750@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ondrej Jirman [ Upstream commit fd90e3808fd2c207560270c39b86b71af2231aa1 ] 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 Signed-off-by: Maxime Ripard Reviewed-by: Jernej Skrabec Link: https://patchwork.freedesktop.org/patch/msgid/20200828125032.937148-1-megous@megous.com Signed-off-by: Sasha Levin --- 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 79eb11cd185d1..9a5584efd5e78 100644 --- a/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c +++ b/drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c @@ -761,7 +761,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; @@ -772,7 +772,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.25.1