[PATCH] tty: ipwireless: fix potential NULL pointer dereference

From: Gustavo A. R. Silva
Date: Mon Jun 05 2017 - 16:50:17 EST


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@xxxxxxxxxxxxxx>
---
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