From 039f88d8077e1d599bbe26515443df85fc184643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Fri, 29 Aug 2014 17:08:02 +0200 Subject: [PATCH] pc_serial: more NULL checks --- .../kernel/drivers/ports/pc_serial/Driver.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp index 852f4b7bc7..db9ea06a65 100644 --- a/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp +++ b/src/add-ons/kernel/drivers/ports/pc_serial/Driver.cpp @@ -480,6 +480,10 @@ next_split: device = new(std::nothrow) SerialDevice(supported, ioport, irq, master); + if (device == NULL) { + TRACE_ALWAYS("can't allocate device\n"); + continue; + } if (pc_serial_insert_device(device) < B_OK) { TRACE_ALWAYS("can't insert device\n"); @@ -522,7 +526,7 @@ scan_isa_hardcoded() SerialDevice *device; device = new(std::nothrow) SerialDevice(&sSupportedDevices[0], sHardcodedPorts[i].ioBase, sHardcodedPorts[i].irq); - if (device && device->Probe()) + if (device != NULL && device->Probe()) pc_serial_insert_device(device); else delete device; @@ -654,6 +658,10 @@ next_split_alt: /**/ device = new(std::nothrow) SerialDevice(supported, ioport, irq, master); + if (device == NULL) { + TRACE_ALWAYS("can't allocate device\n"); + continue; + } if (pc_serial_insert_device(device) < B_OK) { TRACE_ALWAYS("can't insert device\n"); @@ -681,6 +689,9 @@ check_kernel_debug_port() long int value; handle = load_driver_settings("kernel"); + if (handle == NULL) + return; + const char *str = get_driver_parameter(handle, "serial_debug_port", NULL, NULL); if (str != NULL) {