tty: ipwireless: fix possible NULL dereference
authorSudip Mukherjee <sudipm.mukherjee@gmail.com>
Wed, 6 Apr 2016 11:25:39 +0000 (12:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 30 Apr 2016 16:26:55 +0000 (09:26 -0700)
The function alloc_ctrl_packet() can fail and return NULL. Incase it
fails print an error message and exit.

Signed-off-by: Sudip Mukherjee <sudip.mukherjee@codethink.co.uk>
Reviewed-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/ipwireless/hardware.c

index ad7031a..df0204b 100644 (file)
@@ -1572,6 +1572,11 @@ static void handle_received_SETUP_packet(struct ipw_hardware *hw,
                                        sizeof(struct ipw_setup_reboot_msg_ack),
                                        ADDR_SETUP_PROT, TL_PROTOCOLID_SETUP,
                                        TL_SETUP_SIGNO_REBOOT_MSG_ACK);
+                       if (!packet) {
+                               pr_err(IPWIRELESS_PCCARD_NAME
+                                      ": Not enough memory to send reboot packet");
+                               break;
+                       }
                        packet->header.length =
                                sizeof(struct TlSetupRebootMsgAck);
                        send_packet(hw, PRIO_SETUP, &packet->header);