Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp523757yba; Wed, 24 Apr 2019 05:30:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqyKw+1kSBY21SOXSdIuZp+hWOBaYgnyR/RnhGzpI4vfPEHytF2t8GOlliXxsGUkrlTpWgHi X-Received: by 2002:a63:f448:: with SMTP id p8mr30534965pgk.50.1556109014877; Wed, 24 Apr 2019 05:30:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556109014; cv=none; d=google.com; s=arc-20160816; b=bkuJ4Es6VnxkSSR5/MKcNCKNyVbKnrF8mGZkpnAffMK8ZSKVgcPx+ya4MvF1VY0ZKX jXgMxi2I7SEWx3j39ueufvxdeTbGkbfHzkvdT6adFvoYIucN5GN2J8Od1BccBSoM3aiL KlTgjhgbu4bq7yqUn8mei9fjvl6ml11Fext2z6dYzjEbkRUKryxjKIM5rmpwLQ8sMdTJ WuDsoI/OywDPEZSJMYPFd3x8//6MmqcR2CPCeBKVLE4oxjv9P0fuxHSFZNEYhENUVEu4 b1xxHRAV0DwipIqAvJ2pfltvqDfZwqmkzZsLs/1Eb2KpXWptVrOBdEh1cc7K6ESvUONs 1mdg== 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=IVYQXDOV3sPZ9q7TXCkb8aXmL1azsO033o4XZQeD7ik=; b=oE2jlw26cYL+JpupsMDRpuUJRbqzt+wyDH64P48cTDJVJxZ4gwjc1j6DOEiaQPTFyd /eGlDbuQHfu/MVHZcALlhmNTcs4ca3cKvQB32iYzJBpG0v6ss2UpVXlKxJAdnrU0jxLn Ydd6KcDLCCDuxqmnTf1XFSMoC14/Hff6Fk070GtuLruF2tqCJQgN2M1juqU4jcEODvOS 2kJdZiaT4XUsSNZmjmuQM6jaqW514a7BUXhiPqPRehaclg06YxrQGhFAqyJcq6Antoq+ M8uDZkDUO80c9Qv5AfQdKgc6ajePOpms9gkko6qORrzWvUjC0KfgGijPdWaRw5aceNXB IkTw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=df1woK7d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f7si1191619plr.365.2019.04.24.05.29.59; Wed, 24 Apr 2019 05:30:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=df1woK7d; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730073AbfDXM2h (ORCPT + 99 others); Wed, 24 Apr 2019 08:28:37 -0400 Received: from mail-qt1-f195.google.com ([209.85.160.195]:43987 "EHLO mail-qt1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727303AbfDXM2g (ORCPT ); Wed, 24 Apr 2019 08:28:36 -0400 Received: by mail-qt1-f195.google.com with SMTP id g4so572547qtq.10 for ; Wed, 24 Apr 2019 05:28:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=IVYQXDOV3sPZ9q7TXCkb8aXmL1azsO033o4XZQeD7ik=; b=df1woK7doX8rbf7SGvJmnRA7hdZgR6ezmy5D9UJ0UJYKo+/Em8gwOTREV0YMhuT3ho iKoTn4cyVQwVhyHWgTsuBFDA+Iagmu5iFFE7KwNi75lF/aE23WY2dvRh9N0jNiFbs125 eNon7hHdt/fSa+humgcYMC878WpwI3Z6JzSlqnqELa6DaKnH76od6plSDPxcB6zMGwRL /KJ7Z84bUJ1fqWA7w2/u5bLYPf41LMjRMVgI/7bttA+YQvBkcq/GDjxbGAek8GThbMF4 kPb1dBSEJrpW+leZ9ybHedCXUcmBR34IiPL7unOutNMe9SIPk2j2EvGULgZxR0y4I/aT iXXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=IVYQXDOV3sPZ9q7TXCkb8aXmL1azsO033o4XZQeD7ik=; b=Ccx7vWi/02mPFmsyVeEFnBtRcoB9W5PRNtIct88JRnroCH0BYOQQ87XfEYI3QX595g dJofUtvpoOlNnAyUX+fTypj3ltBJOZJVmaALne5QzSLb4xuMhMlyIs+542kCUzu45eQc ncwkV7N/+UX6xM6f0bzPcJkU+igSShQ1ilBb13XSwdvQQ+eyFP6+ETUMWBBHGdkss9m9 C4zSGTwnEjtdDGnVp5NGkp4qqyKZs4VX/LrU3U37pqqbws0E5U1mSmutgNQE9ripWiyR Bj1gB6Ntqlj/jUPN51u5Py6F6JokXNkmnJE/P10Tjjsrj0RD/Bl6G1ogFZxwkNOSmtTf VAUg== X-Gm-Message-State: APjAAAX6wu0dWDyioRFa00kKlAVxwlbqfX4FRtPwAaculmG36vlAQsuQ gD6c9qafe/zMhZKj7LHIZ0NeucYHVS/wCC14iAT7eQ== X-Received: by 2002:a0c:c686:: with SMTP id d6mr16021999qvj.179.1556108916015; Wed, 24 Apr 2019 05:28:36 -0700 (PDT) MIME-Version: 1.0 References: <1554283216-2700-1-git-send-email-yannick.fertre@st.com> <51100130-dfe9-ae21-6efb-b1394f607bdd@st.com> In-Reply-To: <51100130-dfe9-ae21-6efb-b1394f607bdd@st.com> From: Benjamin Gaignard Date: Wed, 24 Apr 2019 14:28:25 +0200 Message-ID: Subject: Re: [PATCH] drm/stm: ltdc: limit number of layer to avoid memory overflow To: Philippe CORNU Cc: Yannick FERTRE , Benjamin GAIGNARD , Vincent ABRIOU , David Airlie , Daniel Vetter , Maxime Coquelin , Alexandre TORGUE , "dri-devel@lists.freedesktop.org" , "linux-stm32@st-md-mailman.stormreply.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" 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 Le ven. 5 avr. 2019 =C3=A0 18:30, Philippe CORNU a = =C3=A9crit : > > Dear Yannick, > Thank you for your patch, > > Acked-by: Philippe Cornu > Applied on drm-misc-next, Thanks, Benjamin > Philippe :) > > On 4/3/19 11:20 AM, Yannick Fertr=C3=A9 wrote: > > If the number of layer is greater than LTDC_MAX_LAYER, we can have > > memory overflow when reading plane_fpsi[]. > > > > Signed-off-by: Yannick Fertr=C3=A9 > > --- > > drivers/gpu/drm/stm/ltdc.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/stm/ltdc.c b/drivers/gpu/drm/stm/ltdc.c > > index 32fd6a3..05bd4b6 100644 > > --- a/drivers/gpu/drm/stm/ltdc.c > > +++ b/drivers/gpu/drm/stm/ltdc.c > > @@ -1021,10 +1021,13 @@ static int ltdc_get_caps(struct drm_device *dde= v) > > struct ltdc_device *ldev =3D ddev->dev_private; > > u32 bus_width_log2, lcr, gc2r; > > > > - /* at least 1 layer must be managed */ > > + /* > > + * at least 1 layer must be managed & the number of layers > > + * must not exceed LTDC_MAX_LAYER > > + */ > > lcr =3D reg_read(ldev->regs, LTDC_LCR); > > > > - ldev->caps.nb_layers =3D max_t(int, lcr, 1); > > + ldev->caps.nb_layers =3D clamp((int)lcr, 1, LTDC_MAX_LAYER); > > > > /* set data bus width */ > > gc2r =3D reg_read(ldev->regs, LTDC_GC2R); > > > _______________________________________________ > dri-devel mailing list > dri-devel@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/dri-devel