[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 10/10] can-host-socketcan: Fix crash when 'if' option is not set
From: |
Eduardo Habkost |
Subject: |
[PULL 10/10] can-host-socketcan: Fix crash when 'if' option is not set |
Date: |
Wed, 14 Oct 2020 10:34:15 -0400 |
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>
---
net/can/can_socketcan.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/net/can/can_socketcan.c b/net/can/can_socketcan.c
index 92b1f79385..4b68f60c6b 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) {
--
2.28.0
- [PULL 00/10] machine + QOM queue, 2020-10-14, Eduardo Habkost, 2020/10/14
- [PULL 02/10] rng-random: register "filename" as class property, Eduardo Habkost, 2020/10/14
- [PULL 01/10] rng-egd: Register "chardev" as class property, Eduardo Habkost, 2020/10/14
- [PULL 04/10] input-linux: Register properties as class properties, Eduardo Habkost, 2020/10/14
- [PULL 05/10] input-barrier: Register properties as class properties, Eduardo Habkost, 2020/10/14
- [PULL 03/10] rng: Register "opened" as class property, Eduardo Habkost, 2020/10/14
- [PULL 06/10] i386: Register most CPU properties as class properties, Eduardo Habkost, 2020/10/14
- [PULL 07/10] vga-pci: Register "big-endian-framebuffer" as class property, Eduardo Habkost, 2020/10/14
- [PULL 10/10] can-host-socketcan: Fix crash when 'if' option is not set,
Eduardo Habkost <=
- [PULL 09/10] authz-list-file: Fix crash when filename is not set, Eduardo Habkost, 2020/10/14
- [PULL 08/10] vhost-user: Register "chardev" as class property, Eduardo Habkost, 2020/10/14
- Re: [PULL 00/10] machine + QOM queue, 2020-10-14, Peter Maydell, 2020/10/15