mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Colin King <colin.king@canonical.com>
To: Chris Metcalf <cmetcalf@ezchip.com>, Joe Perches <joe@perches.com>
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] arch: tile: fix null pointer dereference on pt_regs pointer
Date: Sun,  1 Mar 2015 20:12:26 +0000	[thread overview]
Message-ID: <1425240746-3974-1-git-send-email-colin.king@canonical.com> (raw)

From: Colin Ian King <colin.king@canonical.com>

Cppcheck reports the following issue:
[arch/tile/kernel/stack.c:116]: (error) Possible null
  pointer dereference: p

In this case, on reporting on an odd fault, p is set to NULL
and immediately afterwords p is dereferenced iff
!kbt->profile is false.  Rather than doing this check just
return NULL rather than falling through to the potential
null pointer dereference (since the original intentional
outcome would be to return NULL anyhow) for this odd fault
case.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 arch/tile/kernel/stack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/tile/kernel/stack.c b/arch/tile/kernel/stack.c
index 7ff5afd..2d55c04 100644
--- a/arch/tile/kernel/stack.c
+++ b/arch/tile/kernel/stack.c
@@ -111,7 +111,7 @@ static struct pt_regs *valid_fault_handler(struct KBacktraceIterator* kbt)
 	} else if (kbt->verbose) {
 		pr_err("  (odd fault: pc %#lx, sp %#lx, ex1 %#lx?)\n",
 		       p->pc, p->sp, p->ex1);
-		p = NULL;
+		return NULL;
 	}
 	if (!kbt->profile || ((1ULL << p->faultnum) & QUEUED_INTERRUPTS) == 0)
 		return p;
-- 
2.1.4


             reply	other threads:[~2015-03-01 20:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-01 20:12 Colin King [this message]
2015-03-16 20:15 ` Chris Metcalf

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=1425240746-3974-1-git-send-email-colin.king@canonical.com \
    --to=colin.king@canonical.com \
    --cc=cmetcalf@ezchip.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®