From: abushwang <abushwangs@gmail.com>
To: libc-alpha@sourceware.org, drepper.fsp@gmail.com
Cc: abushwang <abushwangs@gmail.com>
Subject: [PATCH] nptl: fix pthread_mutexattr_gettype always return 0
Date: Fri, 3 Mar 2023 14:34:19 +0800 [thread overview]
Message-ID: <20230303063419.1874310-1-abushwangs@gmail.com> (raw)
According to posix, pthread_mutexattr_gettype will return EINVAL
when the value specified by attr is invalid.
Signed-off-by: abushwang <abushwangs@gmail.com>
---
nptl/pthread_mutexattr_gettype.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/nptl/pthread_mutexattr_gettype.c b/nptl/pthread_mutexattr_gettype.c
index 21e0a9e946..e09dc41e76 100644
--- a/nptl/pthread_mutexattr_gettype.c
+++ b/nptl/pthread_mutexattr_gettype.c
@@ -28,6 +28,9 @@ __pthread_mutexattr_gettype (const pthread_mutexattr_t *attr, int *kind)
*kind = (iattr->mutexkind & ~PTHREAD_MUTEXATTR_FLAG_BITS
& ~PTHREAD_MUTEX_NO_ELISION_NP);
+ if (*kind < PTHREAD_MUTEX_NORMAL || *kind > PTHREAD_MUTEX_ADAPTIVE_NP)
+ return EINVAL;
+
return 0;
}
versioned_symbol (libc, __pthread_mutexattr_gettype,
--
2.36.1
next reply other threads:[~2023-03-03 6:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-03 6:34 abushwang [this message]
2023-03-03 13:01 ` Adhemerval Zanella Netto
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=20230303063419.1874310-1-abushwangs@gmail.com \
--to=abushwangs@gmail.com \
--cc=drepper.fsp@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).