git: 7700d456bff4 - stable/14 - linprocfs: Properly reset error variable for mtab generation

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

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

commit 7700d456bff49383e2e6e8994fd27661757395cf
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:36:18 +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 5c60d4d8e713..9e69c92dc014 100644
--- a/sys/compat/linprocfs/linprocfs.c
+++ b/sys/compat/linprocfs/linprocfs.c
@@ -539,9 +539,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--) {
@@ -561,6 +559,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);