* [PATCH] mtd: lpddr: Added literal suffix
@ 2022-11-17 12:36 Denis Arefev
2022-11-17 14:11 ` Miquel Raynal
0 siblings, 1 reply; 2+ messages in thread
From: Denis Arefev @ 2022-11-17 12:36 UTC (permalink / raw)
To: Miquel Raynal
Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-kernel,
lvc-project, trufanov, vfh
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;
mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift;
mtd->writesize = 1 << lpddr->qinfo->BufSizeShift;
--
2.25.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mtd: lpddr: Added literal suffix
2022-11-17 12:36 [PATCH] mtd: lpddr: Added literal suffix Denis Arefev
@ 2022-11-17 14:11 ` Miquel Raynal
0 siblings, 0 replies; 2+ messages in thread
From: Miquel Raynal @ 2022-11-17 14:11 UTC (permalink / raw)
To: Denis Arefev
Cc: Richard Weinberger, Vignesh Raghavendra, linux-mtd, linux-kernel,
lvc-project, trufanov, vfh
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/
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-11-17 14:12 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 12:36 [PATCH] mtd: lpddr: Added literal suffix Denis Arefev
2022-11-17 14:11 ` Miquel Raynal
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).