public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Gustavo A. R. Silva" <garsilva@embeddedor.com>
To: Jiri Kosina <jikos@kernel.org>, David Sterba <dsterba@suse.com>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jiri Slaby <jslaby@suse.com>
Cc: linux-kernel@vger.kernel.org,
	"Gustavo A. R. Silva" <garsilva@embeddedor.com>
Subject: [PATCH] tty: ipwireless: fix potential NULL pointer dereference
Date: Mon, 5 Jun 2017 15:50:02 -0500	[thread overview]
Message-ID: <20170605205002.GA4896@embeddedgus> (raw)

Add null check before dereferencing pointer ver_packet.
Print error message and exit in case pointer ver_packet
is NULL.

Addresses-Coverity-ID: 1362295
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
---
 drivers/tty/ipwireless/hardware.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c
index df0204b..20db99d 100644
--- a/drivers/tty/ipwireless/hardware.c
+++ b/drivers/tty/ipwireless/hardware.c
@@ -1515,6 +1515,13 @@ static void ipw_send_setup_packet(struct ipw_hardware *hw)
 			sizeof(struct ipw_setup_get_version_query_packet),
 			ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP,
 			TL_SETUP_SIGNO_GET_VERSION_QRY);
+
+	if (!ver_packet) {
+		pr_err(IPWIRELESS_PCCARD_NAME
+		       ": Not enough memory to send packet\n");
+		return;
+	}
+
 	ver_packet->header.length = sizeof(struct tl_setup_get_version_qry);
 
 	/*
-- 
2.5.0

             reply	other threads:[~2017-06-05 20:50 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-05 20:50 Gustavo A. R. Silva [this message]
2017-06-06 10:39 ` [PATCH] tty: ipwireless: fix potential NULL pointer dereference David Sterba

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=20170605205002.GA4896@embeddedgus \
    --to=garsilva@embeddedor.com \
    --cc=dsterba@suse.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jikos@kernel.org \
    --cc=jslaby@suse.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