git: c864c8cf08a9 - releng/13.0 - aio_aqueue(): avoid ucred leak on failure path

From: Mark Johnston <markj_at_FreeBSD.org>
Date: Tue, 09 Aug 2022 20:00:24 UTC
The branch releng/13.0 has been updated by markj:

URL: https://cgit.FreeBSD.org/src/commit/?id=c864c8cf08a9dc197612d5ffffd239aa72de7c97

commit c864c8cf08a9dc197612d5ffffd239aa72de7c97
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-09-24 00:14:56 +0000
Commit:     Mark Johnston <markj@FreeBSD.org>
CommitDate: 2022-07-25 20:01:25 +0000

    aio_aqueue(): avoid ucred leak on failure path
    
    Approved by:    so
    Security:       FreeBSD-SA-22:10.aio
    PR:             258698
    
    (cherry picked from commit 45c2c7c484de7747014492b17ff89e323ee66496)
    (cherry picked from commit 9499d3c1e40dfeb1f63f61af7cdf25ee27f9a2ec)
---
 sys/kern/vfs_aio.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c
index 9b45a06c5f9f..80b7c3ac94e9 100644
--- a/sys/kern/vfs_aio.c
+++ b/sys/kern/vfs_aio.c
@@ -1698,7 +1698,7 @@ no_kqueue:
 	else
 		error = fo_aio_queue(fp, job);
 	if (error)
-		goto err3;
+		goto err4;
 
 	AIO_LOCK(ki);
 	job->jobflags &= ~KAIOCB_QUEUEING;
@@ -1719,6 +1719,8 @@ no_kqueue:
 	AIO_UNLOCK(ki);
 	return (0);
 
+err4:
+	crfree(job->cred);
 err3:
 	if (fp)
 		fdrop(fp, td);