public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Peter Wächtler" <pwaechtler@mac.com>
To: linux-kernel@vger.kernel.org, torvalds@transmeta.com, mingo@elte.hu
Subject: [PATCH] 2.5.43 futex, error in error path
Date: Thu, 17 Oct 2002 18:59:31 +0200	[thread overview]
Message-ID: <3DAEEC73.358660F@mac.com> (raw)

There's an error when the f_setown() call fails.
Not the FD but the return code of f_setown() is free'ed. Oops.
I fixed that by renaming the outer variable "ret" to "fd" - of
course you could rename the inner one to rc or similar.

--- futex.c.orig	2002-10-17 17:29:39.000000000 +0200
+++ futex.c	2002-10-17 18:55:26.000000000 +0200
@@ -352,19 +352,19 @@
 	struct page *page = NULL;
 	struct futex_q *q;
 	struct file *filp;
-	int ret;
+	int fd;
 
-	ret = -EINVAL;
+	fd = -EINVAL;
 	if (signal < 0 || signal > _NSIG)
 		goto out;
 
-	ret = get_unused_fd();
-	if (ret < 0)
+	fd = get_unused_fd();
+	if (fd < 0)
 		goto out;
 	filp = get_empty_filp();
 	if (!filp) {
-		put_unused_fd(ret);
-		ret = -ENFILE;
+		put_unused_fd(fd);
+		fd = -ENFILE;
 		goto out;
 	}
 	filp->f_op = &futex_fops;
@@ -376,7 +376,7 @@
 		
 		ret = f_setown(filp, current->tgid, 1);
 		if (ret) {
-			put_unused_fd(ret);
+			put_unused_fd(fd);
 			put_filp(filp);
 			goto out;
 		}
@@ -385,9 +385,9 @@
 
 	q = kmalloc(sizeof(*q), GFP_KERNEL);
 	if (!q) {
-		put_unused_fd(ret);
+		put_unused_fd(fd);
 		put_filp(filp);
-		ret = -ENOMEM;
+		fd = -ENOMEM;
 		goto out;
 	}
 
@@ -397,7 +397,7 @@
 	if (!page) {
 		unlock_futex_mm();
 
-		put_unused_fd(ret);
+		put_unused_fd(fd);
 		put_filp(filp);
 		kfree(q);
 		return -EFAULT;
@@ -406,17 +406,17 @@
 	init_waitqueue_head(&q->waiters);
 	filp->private_data = q;
 
-	__queue_me(q, page, uaddr, offset, ret, filp);
+	__queue_me(q, page, uaddr, offset, fd, filp);
 
 	unlock_futex_mm();
 
 	/* Now we map fd to filp, so userspace can access it */
-	fd_install(ret, filp);
+	fd_install(fd, filp);
 	page = NULL;
 out:
 	if (page)
 		unpin_page(page);
-	return ret;
+	return fd;
 }
 
 asmlinkage int sys_futex(unsigned long uaddr, int op, int val, struct timespec *utime)

                 reply	other threads:[~2002-10-17 16:52 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3DAEEC73.358660F@mac.com \
    --to=pwaechtler@mac.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=torvalds@transmeta.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox