From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Denis Arefev <arefev@swemel.ru>
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: Re: [PATCH] mtd: lpddr: Added literal suffix
Date: Thu, 17 Nov 2022 15:11:41 +0100 [thread overview]
Message-ID: <20221117151141.20cfc362@xps-13> (raw)
In-Reply-To: <20221117123625.117161-1-arefev@swemel.ru>
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
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
WARNING: multiple messages have this Message-ID (diff)
From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Denis Arefev <arefev@swemel.ru>
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: Re: [PATCH] mtd: lpddr: Added literal suffix
Date: Thu, 17 Nov 2022 15:11:41 +0100 [thread overview]
Message-ID: <20221117151141.20cfc362@xps-13> (raw)
In-Reply-To: <20221117123625.117161-1-arefev@swemel.ru>
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
next prev parent reply other threads:[~2022-11-17 14:12 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 12:36 [PATCH] mtd: lpddr: Added literal suffix Denis Arefev
2022-11-17 12:36 ` Denis Arefev
2022-11-17 14:11 ` Miquel Raynal [this message]
2022-11-17 14:11 ` Miquel Raynal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221117151141.20cfc362@xps-13 \
--to=miquel.raynal@bootlin.com \
--cc=arefev@swemel.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lvc-project@linuxtesting.org \
--cc=richard@nod.at \
--cc=trufanov@swemel.ru \
--cc=vfh@swemel.ru \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.