linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: <linux1394-devel@lists.sourceforge.net>
Cc: yang yeping <yangyeping_666@hotmail.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH] tools/firewire: nosy-dump: check for allocation failure
Date: Mon, 22 Oct 2012 15:17:17 +0200	[thread overview]
Message-ID: <20121022151717.35f585a7@stein> (raw)
In-Reply-To: <BAY167-W2929963ACD86D27998ACE8BB7A0@phx.gbl>

Behavior of null pointer dereference is undefined in the C language.
Portably implement the desired behavior.

Reported-by: Yang Yeping <yangyeping_666@hotmail.com>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
---
 tools/firewire/nosy-dump.c |    4 ++++
 1 file changed, 4 insertions(+)

--- a/tools/firewire/nosy-dump.c
+++ b/tools/firewire/nosy-dump.c
@@ -150,6 +150,8 @@ subaction_create(uint32_t *data, size_t
 
 	/* we put the ack in the subaction struct for easy access. */
 	sa = malloc(sizeof *sa - sizeof sa->packet + length);
+	if (!sa)
+		exit(EXIT_FAILURE);
 	sa->ack = data[length / 4 - 1];
 	sa->length = length;
 	memcpy(&sa->packet, data, length);
@@ -180,6 +182,8 @@ link_transaction_lookup(int request_node
 	}
 
 	t = malloc(sizeof *t);
+	if (!t)
+		exit(EXIT_FAILURE);
 	t->request_node = request_node;
 	t->response_node = response_node;
 	t->tlabel = tlabel;

-- 
Stefan Richter
-=====-===-- =-=- =-==-
http://arcgraph.de/sr/

           reply	other threads:[~2012-10-22 13:17 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <BAY167-W2929963ACD86D27998ACE8BB7A0@phx.gbl>]

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=20121022151717.35f585a7@stein \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux1394-devel@lists.sourceforge.net \
    --cc=yangyeping_666@hotmail.com \
    /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;
as well as URLs for NNTP newsgroup(s).