mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <sha@pengutronix.de>
To: Ahmad Fatoum <a.fatoum@pengutronix.de>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [BUG] mtd: cfi-flash: comparison of unsigned expression in '>= 0' is always true
Date: Tue, 18 May 2021 08:26:45 +0200	[thread overview]
Message-ID: <20210518062645.GU19819@pengutronix.de> (raw)
In-Reply-To: <ce838b2e-bcb8-d13b-8c49-7ffee194094a@pengutronix.de>

Hi Ahmad,

On Mon, May 17, 2021 at 01:29:05PM +0200, Ahmad Fatoum wrote:
> Hi,
> 
> The new warning correctly flags following piece of code in
> drivers/mtd/nor/cfi_flash.c:
> 
> /* loop through the sectors from the highest address
>  * when the passed address is greater or equal to the sector address
>  * we have a match
>  */
> flash_sect_t find_sector(struct flash_info *info, unsigned long addr)
> {
>         flash_sect_t sector;
> 
>         for (sector = info->sector_count - 1; sector >= 0; sector--) {
>                 if (addr >= info->start[sector])
>                         break;
>         }
> 
>         return sector;
> }
> 
> If addr is indeed unmapped by info->start[*], this would be an infinite
> loop. I don't know what the correct fix would be though. Any suggestions?

See
https://lore.barebox.org/20210517185424.32145-7-s.hauer@pengutronix.de

Sascha

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox


      reply	other threads:[~2021-05-18  6:28 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-17 11:29 Ahmad Fatoum
2021-05-18  6:26 ` Sascha Hauer [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=20210518062645.GU19819@pengutronix.de \
    --to=sha@pengutronix.de \
    --cc=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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