mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Serge E. Hallyn" <serue@us.ibm.com>
To: Julio Auto <mindvortex@gmail.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Solar Designer <solar@openwall.com>, Willy Tarreau <w@1wt.eu>,
	linux-kernel@vger.kernel.org,
	"Serge E. Hallyn" <serue@us.ibm.com>
Subject: Re: [PATCH] loop.c: kernel_thread() retval check - 2.6.17.9
Date: Mon, 28 Aug 2006 07:50:06 -0500	[thread overview]
Message-ID: <20060828125006.GC8282@sergelap.austin.ibm.com> (raw)
In-Reply-To: <18d709710608272203q740962rd0c3f2a3be95138b@mail.gmail.com>

Quoting Julio Auto (mindvortex@gmail.com):
> On 8/28/06, Andrew Morton <akpm@osdl.org> wrote:
> >The plan is to stop using the deprecated kernel_thread() in loop 
> >altogether.
> >
> >Please review
> >
> >>ftp://ftp.kernel.org/pub/linux/kernel/people/akpm/patches/2.6/2.6.18-rc4/2.6.18-rc4-mm3/broken-out/kthread-convert-loopc-to-kthread.patch
> >
> 
> Well, the reason behind this patch is just adding a little bit of
> cleanup code (ie., cleaning the 'lo' object) to the case when the
> kernel thread creation fails, regardless of what implementation
> loop_set_fd() uses to accomplish this.
> In fact, I think the concept it's still usable after applying the
> patch you mentioned, since after changing kernel_thread() for
> kthread_create(), the only cleanup code added is setting lo->lo_thread
> to NULL.
> 
> Cheers,
> 
>    Julio Auto

The attached patch does the same resource checks in the kthread version
from 2.6.18-rc4-mm2.

thanks,
-serge

Subject: [PATCH] loop: forward-port resource leak checks from Solar

Forward port of the patch by Solar and ported by Julio, ported
to the -mm tree.

Compiles, boots, and passes my looptorturetest.sh.

Signed-off-by: Serge E. Hallyn <serue@us.ibm.com>

---

 drivers/block/loop.c |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

1a32f47ff67796d8ee8d088d3ba6f54e834e6004
diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index ced8a78..c2e1862 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -826,13 +826,22 @@ static int loop_set_fd(struct loop_devic
 						lo->lo_number);
 	if (IS_ERR(lo->lo_thread)) {
 		error = PTR_ERR(lo->lo_thread);
-		lo->lo_thread = NULL;
-		goto out_putf;
+		goto out_clr;
 	}
 	lo->lo_state = Lo_bound;
 	wake_up_process(lo->lo_thread);
 	return 0;
 
+out_clr:
+	lo->lo_thread = NULL;
+	lo->lo_device = NULL;
+	lo->lo_backing_file = NULL;
+	lo->lo_flags = 0;
+	set_capacity(disks[lo->lo_number], 0);
+	invalidate_bdev(bdev, 0);
+	bd_set_size(bdev, 0);
+	mapping_set_gfp_mask(mapping, lo->old_gfp_mask);
+	lo->lo_state = Lo_unbound;
  out_putf:
 	fput(file);
  out:
-- 
1.1.6

  reply	other threads:[~2006-08-28 12:50 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-08-24  6:41 Julio Auto
2006-08-28  3:55 ` Solar Designer
2006-08-28  4:41   ` Andrew Morton
2006-08-28  5:03     ` Julio Auto
2006-08-28 12:50       ` Serge E. Hallyn [this message]
2006-08-28  4:52   ` Julio Auto

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=20060828125006.GC8282@sergelap.austin.ibm.com \
    --to=serue@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mindvortex@gmail.com \
    --cc=solar@openwall.com \
    --cc=w@1wt.eu \
    /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

all inboxes | Powered by JetHome®