Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3630953pxv; Mon, 12 Jul 2021 23:32:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9NnHr6L4Fu9oHakPHkgZaZKvlU7iKIDyfuA9TORQJXFBcIVIc1zasKTQYjFXCKBwl7lcq X-Received: by 2002:a05:6e02:1d9a:: with SMTP id h26mr1837934ila.308.1626157924547; Mon, 12 Jul 2021 23:32:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626157924; cv=none; d=google.com; s=arc-20160816; b=IVNNsc4hApJhczLuH4xgiVFIroQsiTq2s1ypVhW7mwPRCQLgr03365z/cnfRCZGWD/ WlkUl5MMbMEZAggYxWmXGPmvS8zPwhdEzn8Jy0SCbPefluR1OXltQg5DGAveO7D5NELf /7sO2pWZpSG/PpOoVHcc59mzDWit5Q59YhVHvwvOZNfn3o6SkwxMXNEJXM8rQRYQSNO8 pxRw2ZzSudFlrpMDMnnZgINgi+nzMmk9ttZDiSmfeac96e1w45du4i8zXexFaL2UsA9U XHLWZuGbolsiVkobhzA9QA3WI2oA5vrt31WqV6rJaw1uoAiAIqxIKJKaQBOv8dnNzClJ M+DA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Oxmt79XBu+taOccj92v6QuLkhuYV6I7tDf8b9buNC30=; b=l5jUk+vOq89l+UKqivWcAhO7aexn706BYdviU2B43T3EkNZnd5CzDdNAhM1nI8D+hn WGxvlnIVrdr9v3T1tkcGlbsxXQN5Y/vGPhFIoSIpOCyeJTxBAuRvovSh7iuLU4o6iFYI 2Oc5RMsh6qtOpTHYu3e3KuOSsTYqGBPFQgnv2BOjBOOtjZlGNnBdeFu1eQXV/ieVb9fV BTmxWdDskdU/IeCDQFbz76N9h2Qy/Ep7Ms+K+oDUHlt5Ynx54XovvTXt4pYL+AwT5VHQ UMxiHtieZBjlksDLfnGz6z43darjwu3ZXyfgLPW6j4/sgrONpFw+yXhsPurYc4pnVmno Cvsw== 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 t11si4441319jan.92.2021.07.12.23.31.52; Mon, 12 Jul 2021 23:32:04 -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 S233758AbhGMGdz (ORCPT + 99 others); Tue, 13 Jul 2021 02:33:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233310AbhGMGdy (ORCPT ); Tue, 13 Jul 2021 02:33:54 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24723C0613DD for ; Mon, 12 Jul 2021 23:31:05 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m3BwY-0005bt-Jb; Tue, 13 Jul 2021 08:30:58 +0200 Received: from [2a0a:edc0:0:900:1d::77] (helo=ptz.office.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1m3BwW-0006OT-Hw; Tue, 13 Jul 2021 08:30:56 +0200 Received: from ukl by ptz.office.stw.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1m3BwW-0000mq-Gu; Tue, 13 Jul 2021 08:30:56 +0200 Date: Tue, 13 Jul 2021 08:30:53 +0200 From: Uwe =?utf-8?Q?Kleine-K=C3=B6nig?= To: Salah Triki Cc: fabrice.gasnier@foss.st.com, thierry.reding@gmail.com, lee.jones@linaro.org, mcoquelin.stm32@gmail.com, alexandre.torgue@foss.st.com, linux-pwm@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] divide by 3*sizeof(u32) when computing array_size Message-ID: <20210713063053.qqttzxlopvpnadj3@pengutronix.de> References: <20210712231910.GA1831270@pc> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="ez7arkdudmeg6ooh" Content-Disposition: inline In-Reply-To: <20210712231910.GA1831270@pc> X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --ez7arkdudmeg6ooh Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hello Salah, On Tue, Jul 13, 2021 at 12:19:10AM +0100, Salah Triki wrote: > Divide by 3*sizeof(u32) when computing array_size, since stm32_breakinput > has 3 fields of type u32. >=20 > Signed-off-by: Salah Triki > --- > drivers/pwm/pwm-stm32.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) >=20 > diff --git a/drivers/pwm/pwm-stm32.c b/drivers/pwm/pwm-stm32.c > index 794ca5b02968..fb21bc2b2dd6 100644 > --- a/drivers/pwm/pwm-stm32.c > +++ b/drivers/pwm/pwm-stm32.c > @@ -544,7 +544,7 @@ static int stm32_pwm_probe_breakinputs(struct stm32_p= wm *priv, > return -EINVAL; > =20 > priv->num_breakinputs =3D nb; > - array_size =3D nb * sizeof(struct stm32_breakinput) / sizeof(u32); > + array_size =3D nb * sizeof(struct stm32_breakinput) / (3 * sizeof(u32)); > ret =3D of_property_read_u32_array(np, "st,breakinput", > (u32 *)priv->breakinputs, array_size); > if (ret) I agree with Philipp here; this looks strange and needs a better description. Looking a bit more in details: - priv->breakinputs has type struct stm32_breakinput[MAX_BREAKINPUT] - nb is in [0 .. MAX_BREAKINPUT] - sizeof(struct stm32_breakinput) =3D=3D 3 * sizeof(u32) - of_property_read_u32_array reads $array_size u32 quantities so to read $nb members of type stm32_breakinput array_size must be a multiple of 3 which isn't given any more after your patch. This makes me believe your suggested change to be wrong. Best regards Uwe --=20 Pengutronix e.K. | Uwe Kleine-K=F6nig | Industrial Linux Solutions | https://www.pengutronix.de/ | --ez7arkdudmeg6ooh Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAABCgAdFiEEfnIqFpAYrP8+dKQLwfwUeK3K7AkFAmDtMxoACgkQwfwUeK3K 7AmuxAf/TJUx15z8hdmnrrErJ3Hlc4gXAA+lr7K0fa/zANbA22QYZ4mhmLiNcsca 8XRosInmiaz3M7bEBslrYIMl+vbuLclNt+lTPMeL9V0OcdWtnvZoDnDPpHdE77v1 K10wsl5Uj6HJR27TnXm8VTolsTA5a4VEu4ocU3Ytnx6897ySGKG6wGxpQltn8ulN NtLZ0lIEmB93kF3UpGv2OHqElh1K8FQ6v4a9eREqlXytznMVdiqxQdfygPWZcYvY sY5V3UXdaKuP05bJK6qsmt3hZKT9tZ+4/z7UurgD2FwFe271rGk3+sJ38pyV6vPB AP9WncikXpljRtU/mIEpp/Fu2O4uwA== =OfoS -----END PGP SIGNATURE----- --ez7arkdudmeg6ooh--