All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vivek Goyal <vgoyal@redhat.com>
To: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
Cc: Suresh Jayaraman <sjayaraman@suse.com>, Tejun Heo <tj@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>, Jens Axboe <axboe@kernel.dk>
Subject: Re: Slab corruption in floppy driver module
Date: Fri, 27 Jan 2012 14:54:55 -0500	[thread overview]
Message-ID: <20120127195455.GA18068@redhat.com> (raw)
In-Reply-To: <giaa59tmbr.fsf@mx10.gouders.net>

On Fri, Jan 27, 2012 at 12:30:00PM +0100, Dirk Gouders wrote:
> Suresh Jayaraman <sjayaraman@suse.com> writes:
> 
> > On 01/27/2012 03:18 AM, Dirk Gouders wrote:
> 
> [snipped many lines]
> 
> >> Probably a rare and uncommon one but it seems that the reloading case on
> >> a machine that has a floppy controller is a different problem.  To be
> >> sure I tested the patch on a machine that has a floppy controller and
> >> when unloading and reloading the floppy module the log messages that I
> >> attached to a mail earlier in this thread are still generated.
> >> 
> >
> > Yeah, this seems like a different problem. Could you please try enabling
> > CONFIG_DEBUG_PAGEALLOC and see whether is it pointing to the problem
> > code while loading/unloading the module?
> 
> I enabled the option and it produces just one message during boot but
> nothing else while unloading/loading the floppy module.
>

Can you please try following patch and see if it fixes the issue. I could
reproduce the issue with my virtual machine. The issue seems to be that
we do not call add_disk() for all the drives/disks but we try to do
put_disk() on all the disks. Hence running into the issue of putting
extra reference during module removal.
 

floppy: Fix a crash during rmmmod

floppy driver does not call add_disk() on all the drives hence we don't take
gendisk reference on request queue for these drives. Don't call put_disk()
with disk->queue set, otherwise we try to put the reference we never took.

Reported-by: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de> 
Signed-off-by: Vivek Goyal<vgoyal@redhat.com>
---
 drivers/block/floppy.c |    9 +++++++++
 1 file changed, 9 insertions(+)

Index: linux-2.6/drivers/block/floppy.c
===================================================================
--- linux-2.6.orig/drivers/block/floppy.c	2012-01-27 14:34:45.000000000 -0500
+++ linux-2.6/drivers/block/floppy.c	2012-01-27 14:39:13.729861052 -0500
@@ -4584,6 +4584,15 @@ static void __exit floppy_module_exit(vo
 			platform_device_unregister(&floppy_device[drive]);
 		}
 		blk_cleanup_queue(disks[drive]->queue);
+
+		/*
+		 * These disks have not called add_disk().  Don't put down
+		 * queue reference in put_disk().
+		 */
+		if (!(allowed_drive_mask & (1 << drive)) ||
+		    fdc_state[FDC(drive)].version == FDC_NONE)
+			disks[drive]->queue = NULL;
+
 		put_disk(disks[drive]);
 	}
 

  reply	other threads:[~2012-01-27 19:55 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-24 13:19 Slab corruption in floppy driver module Suresh Jayaraman
2012-01-24 22:31 ` Vivek Goyal
2012-01-25  7:59   ` Dirk Gouders
2012-01-25  9:04     ` Dirk Gouders
2012-01-26 15:04   ` Vivek Goyal
2012-01-26 18:05     ` Tejun Heo
2012-01-26 18:53       ` Dirk Gouders
2012-01-26 19:37       ` Vivek Goyal
2012-01-26 21:48         ` Dirk Gouders
2012-01-26 21:56           ` Vivek Goyal
2012-01-27  6:07           ` Suresh Jayaraman
2012-01-27 11:30             ` Dirk Gouders
2012-01-27 19:54               ` Vivek Goyal [this message]
2012-01-28 10:53                 ` Dirk Gouders
2012-01-29 19:36                 ` Tejun Heo
2012-01-30  6:03                   ` Suresh Jayaraman
2012-01-27  6:03         ` Suresh Jayaraman

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=20120127195455.GA18068@redhat.com \
    --to=vgoyal@redhat.com \
    --cc=axboe@kernel.dk \
    --cc=gouders@et.bocholt.fh-gelsenkirchen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sjayaraman@suse.com \
    --cc=tj@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.