From: Dan Carpenter <dan.carpenter@oracle.com>
To: Geoff Levand <geoff@infradead.org>,
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: kernel-janitors@vger.kernel.org,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: signedness bug in update_flash_db()
Date: Mon, 01 Oct 2018 16:44:58 +0000 [thread overview]
Message-ID: <20181001164458.GB29197@mwanda> (raw)
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)) {
pr_debug("%s: os_area_flash_write failed %zd\n", __func__,
count);
error = count < 0 ? count : -EIO;
WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Geoff Levand <geoff@infradead.org>,
Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
Cc: kernel-janitors@vger.kernel.org,
Paul Mackerras <paulus@samba.org>,
linuxppc-dev@lists.ozlabs.org
Subject: [PATCH] powerpc: signedness bug in update_flash_db()
Date: Mon, 1 Oct 2018 19:44:58 +0300 [thread overview]
Message-ID: <20181001164458.GB29197@mwanda> (raw)
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)) {
pr_debug("%s: os_area_flash_write failed %zd\n", __func__,
count);
error = count < 0 ? count : -EIO;
next reply other threads:[~2018-10-01 16:44 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-01 16:44 Dan Carpenter [this message]
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 18:22 ` christophe leroy
2018-10-01 19:02 ` Dan Carpenter
2018-10-01 19:02 ` Dan Carpenter
2018-10-01 19:06 ` Dan Carpenter
2018-10-01 19:06 ` Dan Carpenter
2018-10-09 11:54 ` Michael Ellerman
2018-10-09 11:54 ` Michael Ellerman
2018-10-01 22:45 ` Geoff Levand
2018-10-01 22:45 ` Geoff Levand
2018-10-15 4:01 ` Michael Ellerman
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=20181001164458.GB29197@mwanda \
--to=dan.carpenter@oracle.com \
--cc=Geert.Uytterhoeven@sonycom.com \
--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 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.