From: Peter Huewe <peterhuewe@gmx.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Devendra Naga <devendra.aaru@gmail.com>,
Peter Huewe <peterhuewe@gmx.de>,
Bill Pemberton <wfp5p@virginia.edu>,
Cruz Julian Bishop <cruzjbishop@gmail.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 4/5] staging/slicoss: Fix buffer possible overflow in slic_card_locate
Date: Tue, 19 Feb 2013 05:18:51 +0100 [thread overview]
Message-ID: <1361247532-1874-4-git-send-email-peterhuewe@gmx.de> (raw)
In-Reply-To: <1361247234-1754-1-git-send-email-peterhuewe@gmx.de>
smatch complains about a possible buffer overflow
slicoss.c:3651 slic_card_locate() error: buffer overflow
'physcard->adapter' 4 <= 4
If the for loop is not exited prematurely i++ is executed after the last
iteration and thus i can be 4, which is out of bounds for
physcard->adapter.
-> Add check for this condition and simplify the if statement by
inverting the condition.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
drivers/staging/slicoss/slicoss.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/slicoss/slicoss.c b/drivers/staging/slicoss/slicoss.c
index fc08585..48056bf 100644
--- a/drivers/staging/slicoss/slicoss.c
+++ b/drivers/staging/slicoss/slicoss.c
@@ -3643,11 +3643,12 @@ static u32 slic_card_locate(struct adapter *adapter)
while (physcard) {
for (i = 0; i < SLIC_MAX_PORTS; i++) {
- if (!physcard->adapter[i])
- continue;
- else
+ if (physcard->adapter[i])
break;
}
+ if (i == SLIC_MAX_PORTS)
+ break;
+
if (physcard->adapter[i]->slotnumber == adapter->slotnumber)
break;
physcard = physcard->next;
--
1.7.8.6
next prev parent reply other threads:[~2013-02-19 4:14 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 4:13 [PATCH 1/5] staging/slicoss: Check pointer before dereferencing Peter Huewe
2013-02-19 4:18 ` [PATCH 2/5] staging/slicoss: Remove always true if statement Peter Huewe
2013-02-19 4:18 ` [PATCH 3/5] staging/slicoss: Fix operation may be undefined warning Peter Huewe
2013-02-19 4:18 ` Peter Huewe [this message]
2013-02-19 4:18 ` [PATCH 5/5] staging/slicoss: Use ether_crc for mac hash calculation Peter Huewe
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=1361247532-1874-4-git-send-email-peterhuewe@gmx.de \
--to=peterhuewe@gmx.de \
--cc=cruzjbishop@gmail.com \
--cc=devel@driverdev.osuosl.org \
--cc=devendra.aaru@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=wfp5p@virginia.edu \
/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
all inboxes | Powered by JetHome®