mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-23 11:39:53 +00:00
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>
This commit is contained in:
parent
14b3948536
commit
d9753cca6b
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user