diff options
author | Thomas Huth <thuth@redhat.com> | 2018-03-16 10:51:29 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-26 14:37:13 +0200 |
commit | 089eac81e1d34d202471c0a023284f47f4c5f00e (patch) | |
tree | 005b5b335514a8b3ea2fa5256cf39aea562899cc /hw/net | |
parent | 4e286099fee107d801f190145de54e47cc5bb3d2 (diff) | |
download | qemu-089eac81e1d34d202471c0a023284f47f4c5f00e.zip qemu-089eac81e1d34d202471c0a023284f47f4c5f00e.tar.gz qemu-089eac81e1d34d202471c0a023284f47f4c5f00e.tar.bz2 |
hw/net/can: Fix segfaults when using the devices without bus
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 <thuth@redhat.com>
Message-Id: <1521193892-15552-2-git-send-email-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/net')
-rw-r--r-- | hw/net/can/can_sja1000.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/hw/net/can/can_sja1000.c b/hw/net/can/can_sja1000.c index 6293233..9a85038 100644 --- a/hw/net/can/can_sja1000.c +++ b/hw/net/can/can_sja1000.c @@ -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; } |