Linux-mtd Archive mirror
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: Denis Arefev <arefev@swemel.ru>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>,
	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: partitions: redboot: Added conversion of operands to a larger type
Date: Mon, 25 Mar 2024 12:30:05 +0200	[thread overview]
Message-ID: <ZgFSLY_uQkfbyyRG@smile.fi.intel.com> (raw)
In-Reply-To: <20240315093758.20790-1-arefev@swemel.ru>

On Fri, Mar 15, 2024 at 12:37:58PM +0300, Denis Arefev wrote:
> The value of an arithmetic expression directory * master->erasesize is
> subject to overflow due to a failure to cast operands to a larger data
> type before perfroming arithmetic

...

> -		offset = directory * master->erasesize;
> +		offset = (unsigned long) directory * master->erasesize;

Usage of explicit casting can be avoided by using size_mul() from overflow.h.
Usually explicit castings are prone to subtle errors.

-- 
With Best Regards,
Andy Shevchenko



______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

      parent reply	other threads:[~2024-03-25 10:30 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-15  9:37 [PATCH] mtd: partitions: redboot: Added conversion of operands to a larger type Denis Arefev
2024-03-25 10:18 ` Miquel Raynal
2024-03-25 10:30 ` Andy Shevchenko [this message]

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=ZgFSLY_uQkfbyyRG@smile.fi.intel.com \
    --to=andriy.shevchenko@intel.com \
    --cc=arefev@swemel.ru \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=miquel.raynal@bootlin.com \
    --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 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 read-only IMAP folder(s) and NNTP newsgroup(s).