Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp2621545ybz; Mon, 27 Apr 2020 00:54:24 -0700 (PDT) X-Google-Smtp-Source: APiQypIHnYtBwHn11MzymcKtH9fLZ1YkK8S9pmETQX4gu0fkwQiqOMVEPeOPRAel7H5wzvxivPCD X-Received: by 2002:a17:906:46da:: with SMTP id k26mr18997681ejs.106.1587974064758; Mon, 27 Apr 2020 00:54:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587974064; cv=none; d=google.com; s=arc-20160816; b=OqQAV6LXLNmxXraV/T0qbcYPk/IlF8smiu9GkoXdT2u/WPy5EJcKu6CXVOlvAkPkYV VOdx7gNHWonZNUju78q+yF0ocXAHgxVzrTJD1u+ni+OM+XsiM6C5xwLQjk14GrA5SVdC 7LE/HHOIJ9K/UAbtO5WMx2t9CCfEX4XIBG8fOxIJA5u4b3ZAPnt8p6AfMooyIIl/gz42 RJnMXhueoQj0RtYc7aKgib4wmw5+QQl9TC/vM+5jXMUB+XAZXkxTxYVdC7tUZ3buvCQN 8sH9Q+df+f6F5+bAPkQUOLCuINWlxbEYLfmIxQ57Dv3Nn3bD3K3ogdYy5+1mYZFzOD7R 2xrg== 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; bh=I7j/giSN89+gw35GKINZdj+AqO5zihyD2mx36BIVynk=; b=A6m7stmvT9cWrOluR3rgkGJBYrvD5MBOgX0Im9IVAj7LUrqQ2M76cSbeG5X+vhXfZk yDdSRVoyFX+fhOoCy99Rp3gsnTn553BofLzibBqBJY+bhXjAbMiTtWWp9Xm6NYaNM9h4 QWcLTeHZDJPFnXo06/95GdPdxjJX9KCB23ynJol/Dauh5cGnyeaAYGlGjshzC8INY/x5 iH05wC3H6YjV9QF/wkJbKnro++HZI96FqYDalNntKaaXesJXxGtsuaPKT9ypft8cSwfd zMVSTbCzSGHqyiERQQePdBOiT+GRPSsN/KTJ3X7lW+4AzpNDKUse6PYdmyt9g3LEIvSp y58A== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b12si7884263ejq.312.2020.04.27.00.54.01; Mon, 27 Apr 2020 00:54:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726407AbgD0Hwr (ORCPT + 99 others); Mon, 27 Apr 2020 03:52:47 -0400 Received: from mail-m17613.qiye.163.com ([59.111.176.13]:11770 "EHLO mail-m17613.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725785AbgD0Hwr (ORCPT ); Mon, 27 Apr 2020 03:52:47 -0400 Received: from ubuntu.localdomain (unknown [157.0.31.122]) by mail-m17613.qiye.163.com (Hmail) with ESMTPA id 58894482675; Mon, 27 Apr 2020 15:52:45 +0800 (CST) From: Bernard Zhao To: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , dri-devel@lists.freedesktop.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org Cc: opensource.kernel@vivo.com, Bernard Zhao Subject: [PATCH] drm/mediatek: cleanup coding style in mediatek a bit Date: Mon, 27 Apr 2020 00:52:38 -0700 Message-Id: <20200427075238.2828-1-bernard@vivo.com> X-Mailer: git-send-email 2.26.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-HM-Spam-Status: e1kfGhgUHx5ZQUtXWQgYFAkeWUFZT1VPTkhCQkJCQk1KQ05IWVdZKFlBSE 83V1ktWUFJV1kJDhceCFlBWTU0KTY6NyQpLjc#WQY+ X-HM-Sender-Digest: e1kMHhlZQR0aFwgeV1kSHx4VD1lBWUc6MzI6Lyo4LzgzPEg8MwIrUUw5 MBRPCg5VSlVKTkNMQkxIQk1OTU9NVTMWGhIXVRkeCRUaCR87DRINFFUYFBZFWVdZEgtZQVlKTkxV S1VISlVKSUlZV1kIAVlBSE9NSDcG X-HM-Tid: 0a71ba9fc6f493bakuws58894482675 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This code change is to make code bit more readable. Optimise array size align to HDMI macro define. Add check if len is overange. Signed-off-by: Bernard Zhao --- drivers/gpu/drm/mediatek/mtk_hdmi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/mediatek/mtk_hdmi.c b/drivers/gpu/drm/mediatek/mtk_hdmi.c index ff43a3d80410..40fb5154ed5d 100644 --- a/drivers/gpu/drm/mediatek/mtk_hdmi.c +++ b/drivers/gpu/drm/mediatek/mtk_hdmi.c @@ -311,15 +311,15 @@ static void mtk_hdmi_hw_send_info_frame(struct mtk_hdmi *hdmi, u8 *buffer, u8 checksum; int ctrl_frame_en = 0; - frame_type = *buffer; - buffer += 1; - frame_ver = *buffer; - buffer += 1; - frame_len = *buffer; - buffer += 1; - checksum = *buffer; - buffer += 1; + frame_type = *buffer++; + frame_ver = *buffer++; + frame_len = *buffer++; + checksum = *buffer++; frame_data = buffer; + if ((frame_len + HDMI_INFOFRAME_HEADER_SIZE) > len) { + dev_err(hdmi->dev, "Wrong frame len: %d\n", frame_len; + return; + } dev_dbg(hdmi->dev, "frame_type:0x%x,frame_ver:0x%x,frame_len:0x%x,checksum:0x%x\n", @@ -982,7 +982,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hdmi *hdmi, struct drm_display_mode *mode) { struct hdmi_avi_infoframe frame; - u8 buffer[17]; + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AVI_INFOFRAME_SIZE]; ssize_t err; err = drm_hdmi_avi_infoframe_from_display_mode(&frame, @@ -1008,7 +1008,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi, const char *product) { struct hdmi_spd_infoframe frame; - u8 buffer[29]; + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_SPD_INFOFRAME_SIZE]; ssize_t err; err = hdmi_spd_infoframe_init(&frame, vendor, product); @@ -1031,7 +1031,7 @@ static int mtk_hdmi_setup_spd_infoframe(struct mtk_hdmi *hdmi, static int mtk_hdmi_setup_audio_infoframe(struct mtk_hdmi *hdmi) { struct hdmi_audio_infoframe frame; - u8 buffer[14]; + u8 buffer[HDMI_INFOFRAME_HEADER_SIZE + HDMI_AUDIO_INFOFRAME_SIZE]; ssize_t err; err = hdmi_audio_infoframe_init(&frame); -- 2.26.2