From 9e42bede2f15055ffa4311741f54a9c829386dc8 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Fri, 9 Nov 2018 11:05:45 -0600 Subject: [PATCH] net/udp/udp_finddev.c: Fallback to netdev_default device if the device is not found, rather than arbitrary using the device at the head of the list of devices. --- net/udp/udp_finddev.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/net/udp/udp_finddev.c b/net/udp/udp_finddev.c index 442b1decea..6846ebcd47 100644 --- a/net/udp/udp_finddev.c +++ b/net/udp/udp_finddev.c @@ -96,16 +96,14 @@ static FAR struct net_driver_s *upd_bound_device(FAR struct udp_conn_s *conn) } } - /* REVISIT: If no device was bound or the bound device is no longer valid, - * then just return the arbitrary device at the head of the list of - * registered devices. This is lunacy if there are multiple, registered - * network devices but makes perfectly good since if there is only one. + /* If no device was bound or the bound device is no longer valid, + * then let's try the default network device. */ - return dev == NULL ? g_netdevices : dev; + return dev == NULL ? netdev_default() : dev; } #else -# define upd_bound_device(c) g_netdevices +# define upd_bound_device(c) netdev_default(); #endif