This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new f71fb738c5 net/icmp: Save poll device in icmp_poll_s
f71fb738c5 is described below

commit f71fb738c5b59fe5c4d3516a4b33052484f7de12
Author: Zhe Weng <[email protected]>
AuthorDate: Tue Jun 6 12:21:49 2023 +0800

    net/icmp: Save poll device in icmp_poll_s
    
    ICMP's conn->dev is changing in icmp_sendmsg, when sending to different
    address, or when error occurs (like NETDEV_DOWN). Then the poll callback
    cannot be dropped from previous dev in free, because the dev is wrong.
    
    So add dev to struct icmp_poll_s just like struct udp_poll_s.
    
    Signed-off-by: Zhe Weng <[email protected]>
---
 net/icmp/icmp.h         | 1 +
 net/icmp/icmp_netpoll.c | 3 ++-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/icmp/icmp.h b/net/icmp/icmp.h
index 21364094ba..071e818a79 100644
--- a/net/icmp/icmp.h
+++ b/net/icmp/icmp.h
@@ -69,6 +69,7 @@ struct devif_callback_s;         /* Forward reference */
 struct icmp_poll_s
 {
   FAR struct socket *psock;        /* IPPROTO_ICMP socket structure */
+  FAR struct net_driver_s *dev;    /* Needed to free the callback structure */
   FAR struct pollfd *fds;          /* Needed to handle poll events */
   FAR struct devif_callback_s *cb; /* Needed to teardown the poll */
 };
diff --git a/net/icmp/icmp_netpoll.c b/net/icmp/icmp_netpoll.c
index 57b5626e38..0fb4f611df 100644
--- a/net/icmp/icmp_netpoll.c
+++ b/net/icmp/icmp_netpoll.c
@@ -181,6 +181,7 @@ int icmp_pollsetup(FAR struct socket *psock, FAR struct 
pollfd *fds)
   /* Initialize the poll info container */
 
   info->psock = psock;
+  info->dev   = conn->dev;
   info->fds   = fds;
   info->cb    = cb;
 
@@ -272,7 +273,7 @@ int icmp_pollteardown(FAR struct socket *psock, FAR struct 
pollfd *fds)
     {
       /* Release the callback */
 
-      icmp_callback_free(conn->dev, conn, info->cb);
+      icmp_callback_free(info->dev, conn, info->cb);
 
       /* Release the poll/select data slot */
 

Reply via email to