public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Samuel Thibault <samuel.thibault@gnu.org>
To: Sergey Bugaev <bugaevc@gmail.com>
Cc: libc-alpha@sourceware.org, bug-hurd@gnu.org
Subject: Re: [PATCH v2 3/4] hurd: Only deallocate addrport when it's valid
Date: Mon, 24 Apr 2023 22:44:31 +0200	[thread overview]
Message-ID: <20230424204431.c36u3etfo63ns7n7@begin> (raw)
In-Reply-To: <20230423160548.126576-3-bugaevc@gmail.com>

Applied, thanks!

Sergey Bugaev, le dim. 23 avril 2023 19:05:47 +0300, a ecrit:
> Signed-off-by: Sergey Bugaev <bugaevc@gmail.com>
> ---
>  sysdeps/mach/hurd/recv.c     | 3 ++-
>  sysdeps/mach/hurd/recvfrom.c | 3 ++-
>  sysdeps/mach/hurd/recvmsg.c  | 3 ++-
>  sysdeps/mach/hurd/sendmsg.c  | 5 +++--
>  sysdeps/mach/hurd/sendto.c   | 2 +-
>  5 files changed, 10 insertions(+), 6 deletions(-)
> 
> diff --git a/sysdeps/mach/hurd/recv.c b/sysdeps/mach/hurd/recv.c
> index 3bd5c16f..1783e38d 100644
> --- a/sysdeps/mach/hurd/recv.c
> +++ b/sysdeps/mach/hurd/recv.c
> @@ -54,7 +54,8 @@ __recv (int fd, void *buf, size_t n, int flags)
>    if (err)
>      return __hurd_sockfail (fd, flags, err);
>  
> -  __mach_port_deallocate (__mach_task_self (), addrport);
> +  if (MACH_PORT_VALID (addrport))
> +    __mach_port_deallocate (__mach_task_self (), addrport);
>    __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);
>  
>    if (bufp != buf)
> diff --git a/sysdeps/mach/hurd/recvfrom.c b/sysdeps/mach/hurd/recvfrom.c
> index 1cd5f917..6f2c927a 100644
> --- a/sysdeps/mach/hurd/recvfrom.c
> +++ b/sysdeps/mach/hurd/recvfrom.c
> @@ -94,7 +94,8 @@ __recvfrom (int fd, void *buf, size_t n, int flags, __SOCKADDR_ARG addrarg,
>    else if (addr_len != NULL)
>      *addr_len = 0;
>  
> -  __mach_port_deallocate (__mach_task_self (), addrport);
> +  if (MACH_PORT_VALID (addrport))
> +    __mach_port_deallocate (__mach_task_self (), addrport);
>  
>    /* Toss control data; we don't care.  */
>    __vm_deallocate (__mach_task_self (), (vm_address_t) cdata, clen);
> diff --git a/sysdeps/mach/hurd/recvmsg.c b/sysdeps/mach/hurd/recvmsg.c
> index 9a37a053..9cf3de48 100644
> --- a/sysdeps/mach/hurd/recvmsg.c
> +++ b/sysdeps/mach/hurd/recvmsg.c
> @@ -135,7 +135,8 @@ __libc_recvmsg (int fd, struct msghdr *message, int flags)
>    else if (message->msg_name != NULL)
>      message->msg_namelen = 0;
>  
> -  __mach_port_deallocate (__mach_task_self (), aport);
> +  if (MACH_PORT_VALID (aport))
> +    __mach_port_deallocate (__mach_task_self (), aport);
>  
>    if (buf == data)
>      buf += len;
> diff --git a/sysdeps/mach/hurd/sendmsg.c b/sysdeps/mach/hurd/sendmsg.c
> index 2f19797b..f9ad7699 100644
> --- a/sysdeps/mach/hurd/sendmsg.c
> +++ b/sysdeps/mach/hurd/sendmsg.c
> @@ -198,8 +198,9 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
>  						   message->msg_controllen,
>  						   &amount);
>  			      LIBC_CANCEL_RESET (cancel_oldtype);
> -			      __mach_port_deallocate (__mach_task_self (),
> -						      aport);
> +			      if (MACH_PORT_VALID (aport))
> +				__mach_port_deallocate (__mach_task_self (),
> +							aport);
>  			    }
>  			  err;
>  			}));
> diff --git a/sysdeps/mach/hurd/sendto.c b/sysdeps/mach/hurd/sendto.c
> index 5a960de8..777af1c4 100644
> --- a/sysdeps/mach/hurd/sendto.c
> +++ b/sysdeps/mach/hurd/sendto.c
> @@ -94,7 +94,7 @@ __sendto (int fd,
>  			  err;
>  			}));
>  
> -  if (aport != MACH_PORT_NULL)
> +  if (MACH_PORT_VALID (aport))
>      __mach_port_deallocate (__mach_task_self (), aport);
>  
>    return err ? __hurd_sockfail (fd, flags, err) : wrote;
> -- 
> 2.40.0
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.

  reply	other threads:[~2023-04-24 20:44 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-23 16:05 [PATCH v2 1/4] hurd: Don't pass FD_CLOEXEC in CMSG_DATA Sergey Bugaev
2023-04-23 16:05 ` [PATCH v2 2/4] hurd: Implement MSG_CMSG_CLOEXEC Sergey Bugaev
2023-04-24 21:10   ` Samuel Thibault
2023-04-24 21:35     ` Sergey Bugaev
2023-04-24 22:18       ` Samuel Thibault
2023-04-23 16:05 ` [PATCH v2 3/4] hurd: Only deallocate addrport when it's valid Sergey Bugaev
2023-04-24 20:44   ` Samuel Thibault [this message]
2023-04-23 16:05 ` [PATCH v2 4/4] socket: Add a test for MSG_CMSG_CLOEXEC Sergey Bugaev
2023-04-24 22:21   ` Samuel Thibault
2023-04-24 21:01 ` [PATCH v2 1/4] hurd: Don't pass FD_CLOEXEC in CMSG_DATA Samuel Thibault
2023-04-24 21:13   ` Sergey Bugaev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230424204431.c36u3etfo63ns7n7@begin \
    --to=samuel.thibault@gnu.org \
    --cc=bug-hurd@gnu.org \
    --cc=bugaevc@gmail.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).