linux-um archives
 help / color / mirror / Atom feed
* [uml-devel] [PATCH 5/5] UML - clean up error path
@ 2005-06-06 20:08 Jeff Dike
  2005-06-06 22:31 ` [uml-devel] " Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Dike @ 2005-06-06 20:08 UTC (permalink / raw)
  To: akpm, torvalds; +Cc: linux-kernel, user-mode-linux-devel

This cleans an error path which used to leak file descriptors by returning
without trying to tidy up.

Signed-off-by: Jeff Dike <jdike@addtoit.com>

Index: linux-2.6.12-rc/arch/um/drivers/chan_user.c
===================================================================
--- linux-2.6.12-rc.orig/arch/um/drivers/chan_user.c	2005-06-02 17:04:11.000000000 -0400
+++ linux-2.6.12-rc/arch/um/drivers/chan_user.c	2005-06-03 17:46:17.000000000 -0400
@@ -143,22 +143,22 @@ static int winch_tramp(int fd, struct tt
 {
 	struct winch_data data;
 	unsigned long stack;
-	int fds[2], pid, n, err;
+	int fds[2], n, err;
 	char c;
 
 	err = os_pipe(fds, 1, 1);
 	if(err < 0){
 		printk("winch_tramp : os_pipe failed, err = %d\n", -err);
-		return(err);
+		goto out;
 	}
 
 	data = ((struct winch_data) { .pty_fd 		= fd,
 				      .pipe_fd 		= fds[1],
 				      .close_me 	= fds[0] } );
-	pid = run_helper_thread(winch_thread, &data, 0, &stack, 0);
-	if(pid < 0){
+	err = run_helper_thread(winch_thread, &data, 0, &stack, 0);
+	if(err < 0){
 		printk("fork of winch_thread failed - errno = %d\n", errno);
-		return(pid);
+		goto out_close;
 	}
 
 	os_close_file(fds[1]);
@@ -168,14 +168,22 @@ static int winch_tramp(int fd, struct tt
 		printk("winch_tramp : failed to read synchronization byte\n");
 		printk("read failed, err = %d\n", -n);
 		printk("fd %d will not support SIGWINCH\n", fd);
-                pid = -1;
+                err = -EINVAL;
+		goto out_close1;
 	}
-	return(pid);
+	return err ;
+
+ out_close:
+	os_close_file(fds[1]);
+ out_close1:
+	os_close_file(fds[0]);
+ out:
+	return err;
 }
 
 void register_winch(int fd, struct tty_struct *tty)
 {
-	int pid, thread, thread_fd;
+	int pid, thread, thread_fd = -1;
 	int count;
 	char c = 1;
 



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [uml-devel] Re: [PATCH 5/5] UML - clean up error path
  2005-06-06 20:08 [uml-devel] [PATCH 5/5] UML - clean up error path Jeff Dike
@ 2005-06-06 22:31 ` Andrew Morton
  2005-06-06 22:35   ` Andrew Morton
  0 siblings, 1 reply; 3+ messages in thread
From: Andrew Morton @ 2005-06-06 22:31 UTC (permalink / raw)
  To: Jeff Dike; +Cc: torvalds, linux-kernel, user-mode-linux-devel

Jeff Dike <jdike@addtoit.com> wrote:
>
> This cleans an error path which used to leak file descriptors by returning
> without trying to tidy up.

The code in 2.6.12-rc6 is quite different from whatever you've patched here.


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [uml-devel] Re: [PATCH 5/5] UML - clean up error path
  2005-06-06 22:31 ` [uml-devel] " Andrew Morton
@ 2005-06-06 22:35   ` Andrew Morton
  0 siblings, 0 replies; 3+ messages in thread
From: Andrew Morton @ 2005-06-06 22:35 UTC (permalink / raw)
  To: jdike, torvalds, linux-kernel, user-mode-linux-devel

Andrew Morton <akpm@osdl.org> wrote:
>
> Jeff Dike <jdike@addtoit.com> wrote:
> >
> > This cleans an error path which used to leak file descriptors by returning
> > without trying to tidy up.
> 
> The code in 2.6.12-rc6 is quite different from whatever you've patched here.

Ah.  Please ignore.  The patches arrived out-of-order, with a huge time gap.


-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-06 22:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-06 20:08 [uml-devel] [PATCH 5/5] UML - clean up error path Jeff Dike
2005-06-06 22:31 ` [uml-devel] " Andrew Morton
2005-06-06 22:35   ` Andrew Morton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox