aboutsummaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorEduardo Habkost <ehabkost@redhat.com>2020-10-08 16:27:12 -0400
committerEduardo Habkost <ehabkost@redhat.com>2020-10-13 15:56:30 -0400
commitd9753cca6b0db724bc6d15e60cfad1705f800b96 (patch)
treecb7bc270cb7c2fa1d9a6fd51afa1c7b9e0a4b6f9 /net
parent14b394853606ab79f1d71f3bbbb4ccaab6538c8f (diff)
downloadqemu-d9753cca6b0db724bc6d15e60cfad1705f800b96.zip
qemu-d9753cca6b0db724bc6d15e60cfad1705f800b96.tar.gz
qemu-d9753cca6b0db724bc6d15e60cfad1705f800b96.tar.bz2
can-host-socketcan: Fix crash when 'if' option is not set
Fix the following crash: $ qemu-system-x86_64 -object can-host-socketcan,id=obj0 Segmentation fault (core dumped) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> Reviewed-by: Li Qiang <liq3ea@gmail.com> Acked-by: Pavel Pisa <pisa@cmp.felk.cvut.cz> Message-Id: <20201008202713.1416823-3-ehabkost@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'net')
-rw-r--r--net/can/can_socketcan.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c
index 92b1f79..4b68f60 100644
--- a/net/can/can_socketcan.c
+++ b/net/can/can_socketcan.c
@@ -194,6 +194,11 @@ static void can_host_socketcan_connect(CanHostState *ch, Error **errp)
struct sockaddr_can addr;
struct ifreq ifr;
+ if (!c->ifname) {
+ error_setg(errp, "'if' property not set");
+ return;
+ }
+
/* open socket */
s = qemu_socket(PF_CAN, SOCK_RAW, CAN_RAW);
if (s < 0) {