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>,
"Robert P. J. Day" <rpjday@crashcourse.ca>,
Joe Perches <joe@perches.com>,
devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: [PATCH 2/2] staging/sep: Check pointers before dereferencing (fix smatch warning)
Date: Tue, 19 Feb 2013 13:07:28 +0100 [thread overview]
Message-ID: <1361275648-6259-2-git-send-email-peterhuewe@gmx.de> (raw)
In-Reply-To: <1361275648-6259-1-git-send-email-peterhuewe@gmx.de>
smatch complains about two dereferenced before check issues:
sep_main.c:2898 sep_free_dma_tables_and_dcb() warn: variable dereferenced before check
'dma_ctx' (see line 2885)
sep_main.c:2898 sep_free_dma_tables_and_dcb() warn: variable dereferenced before check
'*dma_ctx' (see line 2885)
-> Move the checks to the top, but keep the semantics.
Signed-off-by: Peter Huewe <peterhuewe@gmx.de>
---
drivers/staging/sep/sep_main.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/sep/sep_main.c b/drivers/staging/sep/sep_main.c
index 366d56b..f5b7341 100644
--- a/drivers/staging/sep/sep_main.c
+++ b/drivers/staging/sep/sep_main.c
@@ -2880,6 +2880,8 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
dev_dbg(&sep->pdev->dev, "[PID%d] sep_free_dma_tables_and_dcb\n",
current->pid);
+ if (!dma_ctx || !*dma_ctx) /* nothing to be done here*/
+ return 0;
if (((*dma_ctx)->secure_dma == false) && (isapplet == true)) {
dev_dbg(&sep->pdev->dev, "[PID%d] handling applet\n",
@@ -2895,8 +2897,7 @@ static int sep_free_dma_tables_and_dcb(struct sep_device *sep, bool isapplet,
* Go over each DCB and see if
* tail pointer must be updated
*/
- for (i = 0; dma_ctx && *dma_ctx &&
- i < (*dma_ctx)->nr_dcb_creat; i++, dcb_table_ptr++) {
+ for (i = 0; i < (*dma_ctx)->nr_dcb_creat; i++, dcb_table_ptr++) {
if (dcb_table_ptr->out_vr_tail_pt) {
pt_hold = (unsigned long)dcb_table_ptr->
out_vr_tail_pt;
--
1.7.8.6
next prev parent reply other threads:[~2013-02-19 12:03 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-19 12:07 [PATCH 1/2] staging/sep: Fix smatch false positive about potential NULL dereference in sep_main.c Peter Huewe
2013-02-19 12:07 ` Peter Huewe [this message]
2013-02-19 12:25 ` Dan Carpenter
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=1361275648-6259-2-git-send-email-peterhuewe@gmx.de \
--to=peterhuewe@gmx.de \
--cc=devel@driverdev.osuosl.org \
--cc=devendra.aaru@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=rpjday@crashcourse.ca \
/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®