Received: by 2002:ab2:788f:0:b0:1ee:8f2e:70ae with SMTP id b15csp498738lqi; Thu, 7 Mar 2024 03:43:52 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV0EdRJ4HxK1PxvxQNhrlNtdiD0b8E7k/EDw2wUN5zHp5c4QjyWQWn7IHs2e8xuffnXw7W8SP/tYWSkkABk0wYi2OCGy0PaJt+KiT6P9Q== X-Google-Smtp-Source: AGHT+IHCNZCOWA/A54hhbw80z2+tATZ7aUnT0MacbGI6qlui2av9vgxJSSaHDrLhCn7bVvehHzMP X-Received: by 2002:a05:6358:652a:b0:17c:1c76:84b1 with SMTP id v42-20020a056358652a00b0017c1c7684b1mr8985698rwg.14.1709811831946; Thu, 07 Mar 2024 03:43:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709811831; cv=pass; d=google.com; s=arc-20160816; b=EhYm8WOYiF0gFs4r2bzHEgFAkSjO7TXH0tQwZbafvzwsJjAcCToaC/aeF5zEWT6QGG O0BvFgcCVyot2h7Y4VUbF8qlhSpyXc6weL2rz1vU1DKTE4+BgefK96L8SpN/+YnnscKP abRW81EIaEo1VLclCpzMKjo+sdjXh5LelonQf9UW7mkWQB2MegOGv/MszRAN2v68cFwY 60L5h2dsY5vjt6uvXDO2Ak5/edO74X4yEdDwgHeP2egR/2a7YyNFDr3mtoi28Lw+8u6U Eho55dHDMnBYhNK/AF2kmRjYmY/CdnHamuyfxPhQOvs8Fzu+Rd96zPzo3N8yS8HJlcjy 4TeQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:references:in-reply-to :user-agent:subject:cc:to:from:date; bh=1ngiBWNEAB7h3EP9A2EpEtbCgtoR3EKy84YqHGHDjno=; fh=d14+nsH82btcN+HTHbtRlXpWuC/4yLevTtOUetkVBKM=; b=DvdmjmUN5aggPxX3ZhDHh4Uq7T/jpPkCQ2rtW/j0TBUrTwfnhDNQL/qio9+1X7tD4I qlhAODrvbTxvtr24Z/lOzUq8IPvppZsvgEyUTXiEgIF5I/pJgF9EJjkFaNnwtpktrti1 TTkFlt/jmzv4OQ6kotVaVVyf/QxyJCopELTE3onVFUD2zLiB+++BJ4YBYC5ZM0NxvGAl a1Ylx7L/cbvmPnb1J/uGblUWC1bCucbrd8BCxQU6Wd/l6GS2grhNmLMN/oZWu7I/kQN1 9QAosNraHOvtfqm8m6D44JxSimglY2VNCvyyP9aE4Nf62UIplSadsQBCUAfj2RJeNoB8 6SYg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-95453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95453-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id t21-20020a05620a451500b00787c6968d24si18420770qkp.772.2024.03.07.03.43.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 03:43:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-95453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=makrotopia.org); spf=pass (google.com: domain of linux-kernel+bounces-95453-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-95453-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A5E261C218D5 for ; Thu, 7 Mar 2024 11:43:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5040129A6B; Thu, 7 Mar 2024 11:42:45 +0000 (UTC) Received: from pidgin.makrotopia.org (pidgin.makrotopia.org [185.142.180.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 480BF85634 for ; Thu, 7 Mar 2024 11:42:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.142.180.65 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709811765; cv=none; b=IvLShLHgWuHXnv8bpnSZ+Pkj9SHwIPGubkmxtHbbfLoZR8emdENkm9I3hUzZrw3NemhRtApWlh23l7F4wgrRssvosHKrEbX1eEd+I7/CNTKHp3r/dNAMqUquWVdG9BGdeMtLHbuCzRkUUWCkI5amKymRCPuIWj/TiBqBw8ohV5w= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709811765; c=relaxed/simple; bh=HmiysDGoQdQ1CCsY7P4BykmggdQ+5ESOnGLry3+yVEc=; h=Date:From:To:CC:Subject:In-Reply-To:References:Message-ID: MIME-Version:Content-Type; b=Ji9ksq+XS1Ow4q0PF44AWhOPuJrjG7u793OyYw37fpT3+yJj3lKXPmcnqGSXxJKNXcPXFGLP50ljRmXNOvi2mUFFCpH39W28P1dNP+aZck71tLJSS9t5xIHvfpVla8xJFNaHInJ247VCW6NaTeA/4h8Vlq0mHJrneOap2jTKDNI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org; spf=pass smtp.mailfrom=makrotopia.org; arc=none smtp.client-ip=185.142.180.65 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=makrotopia.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=makrotopia.org Received: from local by pidgin.makrotopia.org with esmtpsa (TLS1.3:TLS_AES_128_GCM_SHA256:128) (Exim 4.96.2) (envelope-from ) id 1riC8g-0002VN-2E; Thu, 07 Mar 2024 11:42:18 +0000 Date: Thu, 07 Mar 2024 11:42:12 +0000 From: Daniel Golle To: linux-mtd@lists.infradead.org, Dan Carpenter , Zhihao Cheng CC: Richard Weinberger , Miquel Raynal , Vignesh Raghavendra , linux-kernel@vger.kernel.org, Guenter Roeck , Daniel Diaz , Naresh Kamboju Subject: Re: [PATCH v2] mtd: ubi: fix NVMEM over UBI volumes on 32-bit systems User-Agent: K-9 Mail for Android In-Reply-To: <27c875fb-9507-4034-8468-c4d46c952754@moroto.mountain> References: <31a20aead3419209991bf01aaeaefe07ab94d23a.1709081052.git.daniel@makrotopia.org> <8ae44e8e-fc3d-28bd-5d1e-e900ce53529f@huawei.com> <27c875fb-9507-4034-8468-c4d46c952754@moroto.mountain> Message-ID: <005448D3-A311-4B2D-B515-C7A9399B48E4@makrotopia.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 7 March 2024 09:17:45 UTC, Dan Carpenter = wrote: >On Wed, Feb 28, 2024 at 09:45:13AM +0800, Zhihao Cheng wrote: >> =E5=9C=A8 2024/2/28 8:46, Daniel Golle =E5=86=99=E9=81=93: >> > A compiler warning related to sizeof(int) !=3D 8 when calling do_div(= ) >> > is triggered when building on 32-bit platforms=2E >> > Address this by using integer types having a well-defined size=2E >> >=20 >> > Fixes: 3ce485803da1 ("mtd: ubi: provide NVMEM layer over UBI volumes"= ) >> > Signed-off-by: Daniel Golle >> > --- >> > v2: use size_t for 'bytes_left' variable to match parameter type >> >=20 >> > drivers/mtd/ubi/nvmem=2Ec | 5 ++++- >> > 1 file changed, 4 insertions(+), 1 deletion(-) >> >=20 >> > diff --git a/drivers/mtd/ubi/nvmem=2Ec b/drivers/mtd/ubi/nvmem=2Ec >> > index b7a93c495d172=2E=2Ee68b8589c4279 100644 >> > --- a/drivers/mtd/ubi/nvmem=2Ec >> > +++ b/drivers/mtd/ubi/nvmem=2Ec >> > @@ -23,9 +23,12 @@ struct ubi_nvmem { >> > static int ubi_nvmem_reg_read(void *priv, unsigned int from, >> > void *val, size_t bytes) >> > { >> > - int err =3D 0, lnum =3D from, offs, bytes_left =3D bytes, to_read; >> > struct ubi_nvmem *unv =3D priv; >> > struct ubi_volume_desc *desc; >> > + size_t bytes_left =3D bytes; >> > + uint32_t offs, to_read; >> There still exist a type truncation assignment 'to_read =3D bytes_left'= below, >> although it's safe in logic=2E > >Yeah=2E As you say, from looking at the logic we know it's safe=2E > > 41 if (to_read > bytes_left) > 42 to_read =3D bytes_left; > >Obviously the new value is smaller than the original, so it must fit >within a u32 range=2E=2E=2E I've sent v3 of this fix which should be finally be warning free now=2E https://patchwork=2Eozlabs=2Eorg/project/linux-mtd/patch/ff29447dcee834c17= e4e1e99725b9454c90136ca=2E1709178325=2Egit=2Edaniel@makrotopia=2Eorg/ > >This bug has been breaking the build since Dec 19=2E =20 I have a hard time believing that as the offending commit was only applied= on Feb 25=2E https://git=2Ekernel=2Eorg/pub/scm/linux/kernel/git/next/linux-next=2Egit/= commit/?id=3D3ce485803da1b79b2692b6d0c2792829292ad838 > It's fine if you're >able to manually create your own =2Econfigs to work around build breakage= =2E >But if you're doing automated testing at scale then it's a show stopper= =2E >Could we please fix it=2E > >regards, >dan carpenter > > >______________________________________________________ >Linux MTD discussion mailing list >http://lists=2Einfradead=2Eorg/mailman/listinfo/linux-mtd/