Message ID | 20221117123625.117161-1-arefev@swemel.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp375807wrr; Thu, 17 Nov 2022 04:41:09 -0800 (PST) X-Google-Smtp-Source: AA0mqf6FHiuWcTmS0HCt1hjNSmRr3ASxY+0k7Ihvx5rPOhah4yWcA3myjCgz57FijPGmyUEMmcxY X-Received: by 2002:a05:6a00:4509:b0:562:641b:c1b2 with SMTP id cw9-20020a056a00450900b00562641bc1b2mr2918906pfb.8.1668688869674; Thu, 17 Nov 2022 04:41:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668688869; cv=none; d=google.com; s=arc-20160816; b=Wj4118n91j8J0wyHXU/3+Hf0bz9lYDVJ1NkKhfTNrcSJeD++V9C7xIA8+PWSyQMDvH mG1JnOclJnbfqewTgol4D8CBIzf+kW/tVY9H1s5S341W9KSCOjKprwakgn9wJET/AAN8 p9nEqjQNoaCuQpHRJypxVaN3uWMhwmQ0T/MnT3P1xveUOXkq/HQ2jVucDu9/VpkkgtaM JqRWOQgLH2JsvoS5xxtmlDIRoJT0InjKt0PR58q7fTdtq9wq8hASE9LfZl0+op8t1nBp RZZMiipMXpoEKrDTKHhzekb3nlhrtx3kVKzo8nEhOR5/JU1KHcPkOVCvIbUuCgP251lc NZmA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=z4MrYjbKsvS7dc79yNLvhFfNXfIiOrVHTG1RytCGWi8=; b=ivi16fAXhh470O8pPAMXZrY5seXdFod4IKlsgPIl+e7Jh4Jr8pW8Bq2DRAkx1z+5eC D0ll1X0aH9GZfEGxmE1Z0GEYfk7Gs5wlp8ta8bLyveRW65g87kbbJSz/fGhkafNZJ7h0 nR9CbAZ3eN5PF1yRCvCUGekiyK0z702W4neJjgoilNn0V5chX5jOhFVtN1w7yo2EzWCb kwyy+dbnUIfb8ksZTufJQ0FSPAnXPwe7UZnQRQtgoNJ3RSXbRSU9WHN1Tjahb79XHoD2 llM2nD3k+1yMpsQm6bJa7KUsmjD2h0Cyu3j0Qki5DZ9+Suxyx4K8902KUDdtGscFnl5t r9pQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=MeiXQZPs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c6-20020a63ea06000000b00476a2298bdbsi840175pgi.715.2022.11.17.04.40.56; Thu, 17 Nov 2022 04:41:09 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b=MeiXQZPs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239567AbiKQMgc (ORCPT <rfc822;a1648639935@gmail.com> + 99 others); Thu, 17 Nov 2022 07:36:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234648AbiKQMg2 (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 17 Nov 2022 07:36:28 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 025DEBF7A for <linux-kernel@vger.kernel.org>; Thu, 17 Nov 2022 04:36:28 -0800 (PST) From: Denis Arefev <arefev@swemel.ru> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668688586; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=z4MrYjbKsvS7dc79yNLvhFfNXfIiOrVHTG1RytCGWi8=; b=MeiXQZPs4gKo+k8/Zk6OM1T7WFblVklgTWM8O3lMNnYHzT+s9xXZLpThAe2U87J05vIuXa 1VzXaI5q6S0EZRITeCkrJmzBFAnE+TkKPcPA1R6eJ98wN1sqT+09VCmJdSTMRuD90jN+sT bejmmRgCaulNBGeHc75fzEA+hRjKWPE= To: Miquel Raynal <miquel.raynal@bootlin.com> Cc: Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH] mtd: lpddr: Added literal suffix Date: Thu, 17 Nov 2022 15:36:25 +0300 Message-Id: <20221117123625.117161-1-arefev@swemel.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749747100113651813?= X-GMAIL-MSGID: =?utf-8?q?1749747100113651813?= |
Series |
mtd: lpddr: Added literal suffix
|
|
Commit Message
Denis Arefev
Nov. 17, 2022, 12:36 p.m. UTC
The value of an arithmetic expression
1 << lpddr->qinfo->DevSizeShift is subject to overflow
due to a failure to cast operands to a larger data
type before perfoming arithmetic
Signed-off-by: Denis Arefev <arefev@swemel.ru>
---
drivers/mtd/lpddr/lpddr_cmds.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
Hi Denis, arefev@swemel.ru wrote on Thu, 17 Nov 2022 15:36:25 +0300: > The value of an arithmetic expression > 1 << lpddr->qinfo->DevSizeShift is subject to overflow > due to a failure to cast operands to a larger data > type before perfoming arithmetic > > Signed-off-by: Denis Arefev <arefev@swemel.ru> > --- > drivers/mtd/lpddr/lpddr_cmds.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c > index ee063baed136..360b2af8340b 100644 > --- a/drivers/mtd/lpddr/lpddr_cmds.c > +++ b/drivers/mtd/lpddr/lpddr_cmds.c > @@ -61,7 +61,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map) > mtd->_point = lpddr_point; > mtd->_unpoint = lpddr_unpoint; > } > - mtd->size = 1 << lpddr->qinfo->DevSizeShift; > + mtd->size = 1UL << lpddr->qinfo->DevSizeShift; Are you sure it should not be 1ULL instead? otherwise I don't see how the overflow can happen? > mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift; > mtd->writesize = 1 << lpddr->qinfo->BufSizeShift; > Thanks, Miquèl
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index ee063baed136..360b2af8340b 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c @@ -61,7 +61,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map) mtd->_point = lpddr_point; mtd->_unpoint = lpddr_unpoint; } - mtd->size = 1 << lpddr->qinfo->DevSizeShift; + mtd->size = 1UL << lpddr->qinfo->DevSizeShift; mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift; mtd->writesize = 1 << lpddr->qinfo->BufSizeShift;