git: 3f00a0678b9d - stable/13 - linprocfs: Properly reset error variable for mtab generation

From: Michael Osipov <michaelo_at_FreeBSD.org>
Date: Tue, 31 Dec 2024 12:37:54 UTC
The branch stable/13 has been updated by michaelo:

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

commit 3f00a0678b9de3657d859e590adb3e646aebb2ae
Author:     Michael Osipov <michaelo@FreeBSD.org>
AuthorDate: 2024-12-02 13:25:45 +0000
Commit:     Michael Osipov <michaelo@FreeBSD.org>
CommitDate: 2024-12-31 12:37:39 +0000

    linprocfs: Properly reset error variable for mtab generation
    
    Both functions linprocfs_domtab() and linprocfs_doprocmountinfo() are
    logically identical, but the former fails with ECANCELED because error
    is not reset after the for loop.
    
    Reviewed by:    jrm, fluffy
    MFC after:      2 weeks
    Differential Revision:  https://reviews.freebsd.org/D47865
    
    (cherry picked from commit 58c7db14cd71c41f59d80d26d921782c0c27d523)
---
 sys/compat/linprocfs/linprocfs.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sys/compat/linprocfs/linprocfs.c b/sys/compat/linprocfs/linprocfs.c
index f8bbb0d8fbfc..0a471f684680 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -543,9 +543,7 @@ linprocfs_domtab(PFS_FILL_ARGS)
 	error = kern_getfsstat(td, &buf, SIZE_T_MAX, &count,
 	    UIO_SYSSPACE, MNT_WAIT);
 	if (error != 0) {
-		free(buf, M_TEMP);
-		free(flep, M_TEMP);
-		return (error);
+		goto out;
 	}
 
 	for (sp = buf; count > 0; sp++, count--) {
@@ -565,6 +563,8 @@ linprocfs_domtab(PFS_FILL_ARGS)
 		sbuf_printf(sb, " 0 0\n");
 	}
 
+	error = 0;
+out:
 	free(buf, M_TEMP);
 	free(flep, M_TEMP);
 	return (error);