From: Yongcheng Yang <yoyang@redhat.com>
To: Steve Dickson <steved@redhat.com>
Cc: Linux NFS Mailing list <linux-nfs@vger.kernel.org>,
Herb Wartens <wartens2@llnl.gov>,
Yongcheng Yang <yoyang@redhat.com>
Subject: [PATCH 1/2] rpcb_clnt.c: fix a possible double free
Date: Tue, 1 Aug 2023 17:33:09 +0800 [thread overview]
Message-ID: <20230801093310.594942-2-yoyang@redhat.com> (raw)
In-Reply-To: <20230801093310.594942-1-yoyang@redhat.com>
Signed-off-by: Herb Wartens <wartens2@llnl.gov>
---
src/rpcb_clnt.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/rpcb_clnt.c b/src/rpcb_clnt.c
index d178d86..630f9ad 100644
--- a/src/rpcb_clnt.c
+++ b/src/rpcb_clnt.c
@@ -252,12 +252,16 @@ delete_cache(addr)
for (cptr = front; cptr != NULL; cptr = cptr->ac_next) {
if (!memcmp(cptr->ac_taddr->buf, addr->buf, addr->len)) {
/* Unlink from cache. We'll destroy it after releasing the mutex. */
- if (cptr->ac_uaddr)
+ if (cptr->ac_uaddr) {
free(cptr->ac_uaddr);
- if (prevptr)
+ cptr->ac_uaddr = NULL;
+ }
+ if (prevptr) {
prevptr->ac_next = cptr->ac_next;
- else
+ }
+ else {
front = cptr->ac_next;
+ }
cachesize--;
break;
}
--
2.31.1
next prev parent reply other threads:[~2023-08-01 9:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-01 9:33 [PATCH 0/2] Double-Free and Memory Leak Found In libtirpc Yongcheng Yang
2023-08-01 9:33 ` Yongcheng Yang [this message]
2023-08-01 9:33 ` [PATCH 2/2] rpcb_clnt.c: fix memory leak in destroy_addr Yongcheng Yang
2024-03-15 20:21 ` Wartens, Herb
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=20230801093310.594942-2-yoyang@redhat.com \
--to=yoyang@redhat.com \
--cc=linux-nfs@vger.kernel.org \
--cc=steved@redhat.com \
--cc=wartens2@llnl.gov \
/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