Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp672915ybz; Wed, 29 Apr 2020 07:25:13 -0700 (PDT) X-Google-Smtp-Source: APiQypJk4w742Cd/iXEXr8qyZIucfEc1ytLlWFe+7xaopkTERlwZ802vMErehdBhqvFw/nm8FXqA X-Received: by 2002:a50:951c:: with SMTP id u28mr2609891eda.310.1588170313408; Wed, 29 Apr 2020 07:25:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588170313; cv=none; d=google.com; s=arc-20160816; b=ZUcCk+Tjus+08sZdKlff2TzFDdkDfKMWzJbkOQAvkCWa0npURA6fsR6EhKjqJVS38u btZeNoqe7T+or1TOoqjpQMNko1UXZ5n5DGTEDZwXi7ENbCPDiIRBnJG36S+/DwKWtYME o0GxSHus3/fTZrVQHSnMtjffmDtb1nufA9KyyTwl0c1F0PzofNbXzh4dgq+m3UEGgT8w Mao6cev0qRGIQKLQ7sMNz1A2idte0dR80fGjXy3eJ5x7G9qrs/0ryx67rFk19SlES4DD 9pVt9FzalLkpRMIH0sR7fne5Q+Duevs/oB0uqIqqws1jTxTZfo4qB0ULgJ92h4RpzJ77 fk2A== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GXxkZpR+RkV9NPD0lYVAuWUJY9e1/fwjuALcfX8fn7Q=; b=pxIWd3npKzfQRVd7dfbOBqbTmXW9jCyNJlc3OSXnG9QiDlwhArlgu0WYBab/hoGuhj I6z3+NVMu8LBpRsKpjPlvzn6jYiVWYkcJWtlMr7REupcNOU4hlkhUdtPxCjjlDg26em9 /Ws3HoQevFqOeHYTEfX2eDcQEEbZU/nckVKhTs0nZCEddaBq6qPNrIbMt69qIk5OoLqk Yl7k9/e0mi66/wh5dOvQPILwjc/8tk9r0RZiE1iPySey5TmYX9fQ3Tr5Fp+QXJMlc+Go Flo2M7PyyOvFvbW2ytyWpkz6komieXsg04fnT4i5LsRfLA+7Iwb8HfIrdRQKlFCPJQ3O Eiig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=PetStyHL; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m7si3871585ejr.512.2020.04.29.07.24.49; Wed, 29 Apr 2020 07:25:13 -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=PetStyHL; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727992AbgD2OXF (ORCPT + 99 others); Wed, 29 Apr 2020 10:23:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:48824 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727865AbgD2OXF (ORCPT ); Wed, 29 Apr 2020 10:23:05 -0400 Received: from mail-ej1-f45.google.com (mail-ej1-f45.google.com [209.85.218.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 66A3B2186A for ; Wed, 29 Apr 2020 14:23:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588170184; bh=G66dtQxbgcy1h44rcbSXdxCegSH9fBKXU5OqSZIxS8g=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=PetStyHLEV2lrSXAVs6D/TdlIhWhS1z8l9Gl+vM/4MNdlQd4o+6yNZktsNtNHZQU6 YIHcHaxmLo83AxCXmV1gKViG3iVFBBJBxN8LECtjbSqWDS7oeQIrFEsrWRfIgb3q0s Ur2XeOWeKdtohhLwNWX4xkXhaSx8gpjuNR5Cl7aI= Received: by mail-ej1-f45.google.com with SMTP id nv1so1719405ejb.0 for ; Wed, 29 Apr 2020 07:23:04 -0700 (PDT) X-Gm-Message-State: AGi0PuaTfdV8OP0rs7ASMLn1SY0cQ/zUGePyUgJKVqBiYx6BjlgsgWjj mo9DmL4ttG4ZIZO802DQjfDetxzt7JggO/1Alg== X-Received: by 2002:a17:906:2ad4:: with SMTP id m20mr2875207eje.324.1588170182786; Wed, 29 Apr 2020 07:23:02 -0700 (PDT) MIME-Version: 1.0 References: <20200427075238.2828-1-bernard@vivo.com> In-Reply-To: <20200427075238.2828-1-bernard@vivo.com> From: Chun-Kuang Hu Date: Wed, 29 Apr 2020 22:22:50 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] drm/mediatek: cleanup coding style in mediatek a bit To: Bernard Zhao Cc: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , DRI Development , Linux ARM , "moderated list:ARM/Mediatek SoC support" , linux-kernel , opensource.kernel@vivo.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Bernard: Bernard Zhao =E6=96=BC 2020=E5=B9=B44=E6=9C=8827=E6=97= =A5 =E9=80=B1=E4=B8=80 =E4=B8=8B=E5=8D=883:53=E5=AF=AB=E9=81=93=EF=BC=9A > > This code change is to make code bit more readable. > Optimise array size align to HDMI macro define. > Add check if len is overange. One patch should just do one thing, but this do three things. So break this into three patches. Regards, Chun-Kuang. > > 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/mediat= ek/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 =3D 0; > > - frame_type =3D *buffer; > - buffer +=3D 1; > - frame_ver =3D *buffer; > - buffer +=3D 1; > - frame_len =3D *buffer; > - buffer +=3D 1; > - checksum =3D *buffer; > - buffer +=3D 1; > + frame_type =3D *buffer++; > + frame_ver =3D *buffer++; > + frame_len =3D *buffer++; > + checksum =3D *buffer++; > frame_data =3D 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:0= x%x\n", > @@ -982,7 +982,7 @@ static int mtk_hdmi_setup_avi_infoframe(struct mtk_hd= mi *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 =3D 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 =3D 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 =3D hdmi_audio_infoframe_init(&frame); > -- > 2.26.2 > > > _______________________________________________ > Linux-mediatek mailing list > Linux-mediatek@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/linux-mediatek