]> Git Repo - qemu.git/commitdiff
hw/net/can: Fix segfaults when using the devices without bus
authorThomas Huth <[email protected]>
Fri, 16 Mar 2018 09:51:29 +0000 (10:51 +0100)
committerPaolo Bonzini <[email protected]>
Mon, 26 Mar 2018 12:37:13 +0000 (14:37 +0200)
The CAN devices can currently be used to crash QEMU, e.g.:

$ x86_64-softmmu/qemu-system-x86_64 -device kvaser_pci
Segmentation fault (core dumped)

So we've got to add a proper check here that the corresponding
bus is available.

Signed-off-by: Thomas Huth <[email protected]>
Message-Id: <1521193892[email protected]>
Signed-off-by: Paolo Bonzini <[email protected]>
hw/net/can/can_sja1000.c

index 629323312cfa2758737fa8cc1fdc771177ff26af..9a85038c8ad0095472bc6db39554d4bce53cd593 100644 (file)
@@ -866,6 +866,10 @@ int can_sja_connect_to_bus(CanSJA1000State *s, CanBusState *bus)
 {
     s->bus_client.info = &can_sja_bus_client_info;
 
+    if (!bus) {
+        return -EINVAL;
+    }
+
     if (can_bus_insert_client(bus, &s->bus_client) < 0) {
         return -1;
     }
This page took 0.028563 seconds and 4 git commands to generate.