mount: avoid po_destroy to modify errno what we really want
diff mbox

Message ID 4CEE357D.2030007@cn.fujitsu.com
State RFC, archived
Headers show

Commit Message

Mi Jinlong Nov. 25, 2010, 10:07 a.m. UTC
None

Patch
diff mbox

diff --git a/utils/mount/stropts.c b/utils/mount/stropts.c
index 50a1a2a..d554877 100644
--- a/utils/mount/stropts.c
+++ b/utils/mount/stropts.c
@@ -592,7 +592,7 @@  static int nfs_do_mount_v3v2(struct nfsmount_info *mi,
 		struct sockaddr *sap, socklen_t salen)
 {
 	struct mount_options *options = po_dup(mi->options);
-	int result = 0;
+	int result = 0, save = 0;
 
 	if (!options) {
 		errno = ENOMEM;
@@ -637,7 +637,9 @@  static int nfs_do_mount_v3v2(struct nfsmount_info *mi,
 	result = nfs_sys_mount(mi, options);
 
 out_fail:
+	save = errno;
 	po_destroy(options);
+	errno = save;
 	return result;
 }
 
@@ -673,7 +675,7 @@  static int nfs_do_mount_v4(struct nfsmount_info *mi,
 		struct sockaddr *sap, socklen_t salen)
 {
 	struct mount_options *options = po_dup(mi->options);
-	int result = 0;
+	int result = 0, save = 0;
 
 	if (!options) {
 		errno = ENOMEM;
@@ -724,7 +726,9 @@  static int nfs_do_mount_v4(struct nfsmount_info *mi,
 	result = nfs_sys_mount(mi, options);
 
 out_fail:
+	save = errno;
 	po_destroy(options);
+	errno = save;
 	return result;
 }