From: Dan Carpenter <dan.carpenter@oracle.com>
To: christophe leroy <christophe.leroy@c-s.fr>
Cc: Geoff Levand <geoff@infradead.org>,
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>,
kernel-janitors@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
Paul Mackerras <paulus@samba.org>
Subject: Re: [PATCH] powerpc: signedness bug in update_flash_db()
Date: Mon, 01 Oct 2018 19:02:54 +0000 [thread overview]
Message-ID: <20181001190254.vtuop3jqh5vrvwtq@mwanda> (raw)
In-Reply-To: <6fa5827e-3346-4057-ca44-c6d9758f5837@c-s.fr>
On Mon, Oct 01, 2018 at 08:22:01PM +0200, christophe leroy wrote:
>
>
> Le 01/10/2018 à 18:44, Dan Carpenter a écrit :
> > The "count < sizeof(struct os_area_db)" comparison is type promoted to
> > size_t so negative values of "count" are treated as very high values and
> > we accidentally return success instead of a negative error code.
> >
> > This doesn't really change runtime much but it fixes a static checker
> > warning.
> >
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> >
> > diff --git a/arch/powerpc/platforms/ps3/os-area.c b/arch/powerpc/platforms/ps3/os-area.c
> > index cdbfc5cfd6f3..f5387ad82279 100644
> > --- a/arch/powerpc/platforms/ps3/os-area.c
> > +++ b/arch/powerpc/platforms/ps3/os-area.c
> > @@ -664,7 +664,7 @@ static int update_flash_db(void)
> > db_set_64(db, &os_area_db_id_rtc_diff, saved_params.rtc_diff);
> > count = os_area_flash_write(db, sizeof(struct os_area_db), pos);
> > - if (count < sizeof(struct os_area_db)) {
> > + if (count < 0 || count < sizeof(struct os_area_db)) {
>
> Why not simply add a cast ? :
>
> if (count < (ssize_t)sizeof(struct os_area_db)) {
>
There are so many ways to solve these and no accounting for taste. Do
you need me to resend or can you redo it yourself?
regards,
dan carpenter
next prev parent reply other threads:[~2018-10-01 19:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 16:44 [PATCH] powerpc: signedness bug in update_flash_db() Dan Carpenter
2018-10-01 18:22 ` christophe leroy
2018-10-01 19:02 ` Dan Carpenter [this message]
2018-10-01 19:06 ` Dan Carpenter
2018-10-09 11:54 ` Michael Ellerman
2018-10-01 22:45 ` Geoff Levand
2018-10-15 4:01 ` Michael Ellerman
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=20181001190254.vtuop3jqh5vrvwtq@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--cc=christophe.leroy@c-s.fr \
--cc=geoff@infradead.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.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