Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp922304ybc; Tue, 12 Nov 2019 11:17:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwNxAf+h1sBINhT+G1R37tKep/v2r4X/Uxjj1muHklWheloJ7RUKnQn9OLeb9kVwYUayX1U X-Received: by 2002:a50:fc1a:: with SMTP id i26mr35772156edr.9.1573586249607; Tue, 12 Nov 2019 11:17:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573586249; cv=none; d=google.com; s=arc-20160816; b=TiEq8F9T3QoyvOsxFFqDaatNf6CEyczZYJGfXAbudCT0fQ/KdbTVemQ3qzjC7v52fy mXBXvQw35rmwicDXtIbDC/LRAL/YVrSvujMRVnZAr1+PhdRQpEgOK+BuUvalhWtF5exN oODvvGrCmI5MxvGfL4OT/2BDkceRvz1lloygRG5ZnjzrMHGDWp/zQE+i1Pub3WbD4UvZ 1zv4Xh2lJEoBVNR3y7Czl95FeYjl/bSBwYLFzSJ6j/XMCv8vKuHjEcLyUiwxQWRWvntb sTfMF+uFQey7nN5y5IsCDXosvis8MK/22sHPU5Ps4oX1xO2QB8Ied+gILHYgVyiarb5Z PDXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=sHevwGELwKIIKRwH9XhoqjUm6k2qcVwt+pWUUZLwtuY=; b=N83LmLs0vh3BMU/zHzHTDROaF2iEfOjfOFHY8t6yEEP7w+Iti/68A/eOp/9+L0pwhx d1+ESUwFel85EX8KNHjL1Y+8mYdMjk6QudA9YF1dqmoDfQf8knVq6c31ApKQphzmRsCz tMcyoRnB1ApwG/UNbsF5P4GuEja7FMwjR4i96IwM5wO5bqk0Io0/XJfUPN7OkafYEaEJ mcU50RDgGqP5Hu3hVXlhDoY7SW8FTfSsADz1SrEtPn1dpIO3D5ZNTh/2DcSa1PMaF9zy hBs5iUIVNlVb2pi7uBXuPY5SecdeX0tZoxHW6dDZ4yqN2GaE6dNMYm+iRVvdnna3eOsN 6BTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rL470w9j; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id qw26si640894ejb.103.2019.11.12.11.17.05; Tue, 12 Nov 2019 11:17:29 -0800 (PST) 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=@kernel.org header.s=default header.b=rL470w9j; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbfKLTQX (ORCPT + 99 others); Tue, 12 Nov 2019 14:16:23 -0500 Received: from mail.kernel.org ([198.145.29.99]:35922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725997AbfKLTQW (ORCPT ); Tue, 12 Nov 2019 14:16:22 -0500 Received: from localhost (lfbn-1-10718-76.w90-89.abo.wanadoo.fr [90.89.68.76]) (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 E189D20818; Tue, 12 Nov 2019 19:16:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1573586181; bh=1IW8UUMmQ1aplMh8cmJEkKKNsjASki0Ab44VZOslaPk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rL470w9j47ztbIN8itCRbCXBV+CYT0FjVIdVe/g+CYnW8SJ7yi+ynGw67CJ03Cpw8 bQ66XQbLq/LZeMR2BxY9RH4v1Kq7cZUA0MvpkY+Z42A9VldZK/dVOsE6koLlvTlDWm IOinDXU7oult1Vdrdk+foCXekQfEG2ybYOTuUEoM= Date: Tue, 12 Nov 2019 20:16:18 +0100 From: Maxime Ripard To: Icenowy Zheng Cc: linux-arm-kernel@lists.infradead.org, Tian Yunhao , Stephen Boyd , Michael Turquette , "linux-kernel@vger.kernel.org" , Chen-Yu Tsai , "linux-clk@vger.kernel.org" Subject: Re: [PATCH] clk: sunxi-ng: v3s: Fix incorrect number of hw_clks. Message-ID: <20191112191618.GC4345@gilmour.lan> References: <20191111123936.GM4345@gilmour.lan> <1FA73EE3-CED2-4241-839D-51C8C02531F5@aosc.io> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="alCHniwhwUTljuKz" Content-Disposition: inline In-Reply-To: <1FA73EE3-CED2-4241-839D-51C8C02531F5@aosc.io> User-Agent: Mutt/1.12.1 (2019-06-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --alCHniwhwUTljuKz Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Nov 12, 2019 at 08:59:56PM +0800, Icenowy Zheng wrote: > > > =E4=BA=8E 2019=E5=B9=B411=E6=9C=8811=E6=97=A5 GMT+08:00 =E4=B8=8B=E5=8D= =888:39:36, Maxime Ripard =E5=86=99=E5=88=B0: > >Hi, > > > >Thanks for your patch > > > >On Sat, Nov 09, 2019 at 03:19:09PM +0000, Tian Yunhao wrote: > >> The hws field of sun8i_v3s_hw_clks has only 74 > >> members. However, the number specified by CLK_NUMBER > >> is 77 (=3D CLK_I2S0 + 1). This leads to runtime segmentation > >> fault that is not always reproducible. > >> > >> This patch adds a protective field [CLK_NUMBER] which ensures > >> ARRAY_SIZE(.hws) is always greater than .num, thus eliminates > >> this error. > >> > >> Signed-off-by: Yunhao Tian > >> --- > >> drivers/clk/sunxi-ng/ccu-sun8i-v3s.c | 2 ++ > >> 1 file changed, 2 insertions(+) > >> > >> diff --git a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c > >b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c > >> index 5c779eec454b..de7fce7f32e6 100644 > >> --- a/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c > >> +++ b/drivers/clk/sunxi-ng/ccu-sun8i-v3s.c > >> @@ -617,6 +617,7 @@ static struct clk_hw_onecell_data > >sun8i_v3s_hw_clks =3D { > >> [CLK_AVS] =3D &avs_clk.common.hw, > >> [CLK_MBUS] =3D &mbus_clk.common.hw, > >> [CLK_MIPI_CSI] =3D &mipi_csi_clk.common.hw, > >> + [CLK_NUMBER] =3D NULL, > >> }, > >> .num =3D CLK_NUMBER, > >> }; > >> @@ -699,6 +700,7 @@ static struct clk_hw_onecell_data > >sun8i_v3_hw_clks =3D { > >> [CLK_AVS] =3D &avs_clk.common.hw, > >> [CLK_MBUS] =3D &mbus_clk.common.hw, > >> [CLK_MIPI_CSI] =3D &mipi_csi_clk.common.hw, > >> + [CLK_NUMBER] =3D NULL, > >> }, > >> .num =3D CLK_NUMBER, > > > >I'd rather have the number of clocks (.num) being properly set. > > However the maximum clock indices number is different on V3s and V3, beca= use > on V3s the last clock is missing. > > Should we define CLK_NUMBER_V3S here? That, or we can just reference the last clock, we're not using CLK_NUMBER anywhere else. Maxime --alCHniwhwUTljuKz Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYIAB0WIQRcEzekXsqa64kGDp7j7w1vZxhRxQUCXcsFAgAKCRDj7w1vZxhR xRGMAQCLdf1+S5MiugOG811D1O+TID2K8oHSTiGL0ebwb1WnzQD/RoJSiEPXRiwL 00DWv7QWDbWvFN/sZUAK3pqmsgjjZwA= =jeP6 -----END PGP SIGNATURE----- --alCHniwhwUTljuKz--