linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] floppy: Fix couple of crashes during init and module removal
@ 2012-01-30 14:59 Vivek Goyal
  2012-01-30 14:59 ` [PATCH 1/2] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called Vivek Goyal
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Vivek Goyal @ 2012-01-30 14:59 UTC (permalink / raw)
  To: linux-kernel, axboe; +Cc: tj, sjayaraman, gouders, vgoyal

Hi Jens,

Here are couple of fixes for floppy driver. These fixes need to go in for 3.3.
Original discussion thread is here.

https://lkml.org/lkml/2012/1/24/138

I am reposting the patches in a separate thread as it might be easier for you
to pick up the patches.

Thanks
Vivek

Vivek Goyal (2):
  floppy: Cleanup disk->queue before caling put_disk() if add_disk()
    was never called
  floppy: Fix a crash during rmmod

 drivers/block/floppy.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

-- 
1.7.4.4


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

* [PATCH 1/2] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called
  2012-01-30 14:59 [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
@ 2012-01-30 14:59 ` Vivek Goyal
  2012-01-30 14:59 ` [PATCH 2/2] floppy: Fix a crash during rmmod Vivek Goyal
  2012-02-08 18:14 ` [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
  2 siblings, 0 replies; 5+ messages in thread
From: Vivek Goyal @ 2012-01-30 14:59 UTC (permalink / raw)
  To: linux-kernel, axboe; +Cc: tj, sjayaraman, gouders, vgoyal

add_disk() takes gendisk reference on request queue. If driver failed during
initialization and never called add_disk() then that extra reference is not
taken. That reference is put in put_disk(). floppy driver allocates the
disk, allocates queue, sets disk->queue and then relizes that floppy
controller is not present. It tries to tear down everything and tries to
put a reference down in put_disk() which was never taken.

In such error cases cleanup disk->queue before calling put_disk() so that
we never try to put down a reference which was never taken in first place.

Reported-and-tested-by: Suresh Jayaraman <sjayaraman@suse.com>
Tested-by: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
Signed-off-by: Vivek Goyal <vgoyal@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 drivers/block/floppy.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 510fb10..401ba78 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4368,8 +4368,14 @@ out_unreg_blkdev:
 out_put_disk:
 	while (dr--) {
 		del_timer_sync(&motor_off_timer[dr]);
-		if (disks[dr]->queue)
+		if (disks[dr]->queue) {
 			blk_cleanup_queue(disks[dr]->queue);
+			/*
+			 * put_disk() is not paired with add_disk() and
+			 * will put queue reference one extra time. fix it.
+			 */
+			disks[dr]->queue = NULL;
+		}
 		put_disk(disks[dr]);
 	}
 	return err;
-- 
1.7.4.4


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

* [PATCH 2/2] floppy: Fix a crash during rmmod
  2012-01-30 14:59 [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
  2012-01-30 14:59 ` [PATCH 1/2] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called Vivek Goyal
@ 2012-01-30 14:59 ` Vivek Goyal
  2012-02-08 18:14 ` [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
  2 siblings, 0 replies; 5+ messages in thread
From: Vivek Goyal @ 2012-01-30 14:59 UTC (permalink / raw)
  To: linux-kernel, axboe; +Cc: tj, sjayaraman, gouders, vgoyal

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-and-tested-by: Dirk Gouders <gouders@et.bocholt.fh-gelsenkirchen.de>
Signed-off-by: Vivek Goyal<vgoyal@redhat.com>
Acked-by: Tejun Heo <tj@kernel.org>
---
 drivers/block/floppy.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 401ba78..9baf11e 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4585,6 +4585,15 @@ static void __exit floppy_module_exit(void)
 			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]);
 	}
 
-- 
1.7.4.4


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

* Re: [PATCH 0/2] floppy: Fix couple of crashes during init and module removal
  2012-01-30 14:59 [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
  2012-01-30 14:59 ` [PATCH 1/2] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called Vivek Goyal
  2012-01-30 14:59 ` [PATCH 2/2] floppy: Fix a crash during rmmod Vivek Goyal
@ 2012-02-08 18:14 ` Vivek Goyal
  2012-02-08 19:03   ` Jens Axboe
  2 siblings, 1 reply; 5+ messages in thread
From: Vivek Goyal @ 2012-02-08 18:14 UTC (permalink / raw)
  To: axboe; +Cc: tj, sjayaraman, gouders, linux kernel mailing list

On Mon, Jan 30, 2012 at 09:59:49AM -0500, Vivek Goyal wrote:
> Hi Jens,
> 
> Here are couple of fixes for floppy driver. These fixes need to go in for 3.3.
> Original discussion thread is here.
> 
> https://lkml.org/lkml/2012/1/24/138
> 
> I am reposting the patches in a separate thread as it might be easier for you
> to pick up the patches.
> 

Hi Jens,

Can you please apply these two floppy driver fixes.

Thanks
Vivek

> Thanks
> Vivek
> 
> Vivek Goyal (2):
>   floppy: Cleanup disk->queue before caling put_disk() if add_disk()
>     was never called
>   floppy: Fix a crash during rmmod
> 
>  drivers/block/floppy.c |   17 ++++++++++++++++-
>  1 files changed, 16 insertions(+), 1 deletions(-)
> 
> -- 
> 1.7.4.4

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

* Re: [PATCH 0/2] floppy: Fix couple of crashes during init and module removal
  2012-02-08 18:14 ` [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
@ 2012-02-08 19:03   ` Jens Axboe
  0 siblings, 0 replies; 5+ messages in thread
From: Jens Axboe @ 2012-02-08 19:03 UTC (permalink / raw)
  To: Vivek Goyal; +Cc: tj, sjayaraman, gouders, linux kernel mailing list

On 02/08/2012 07:14 PM, Vivek Goyal wrote:
> On Mon, Jan 30, 2012 at 09:59:49AM -0500, Vivek Goyal wrote:
>> Hi Jens,
>>
>> Here are couple of fixes for floppy driver. These fixes need to go in for 3.3.
>> Original discussion thread is here.
>>
>> https://lkml.org/lkml/2012/1/24/138
>>
>> I am reposting the patches in a separate thread as it might be easier for you
>> to pick up the patches.
>>
> 
> Hi Jens,
> 
> Can you please apply these two floppy driver fixes.

Yep, thanks, applied.

-- 
Jens Axboe


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

end of thread, other threads:[~2012-02-08 19:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-30 14:59 [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
2012-01-30 14:59 ` [PATCH 1/2] floppy: Cleanup disk->queue before caling put_disk() if add_disk() was never called Vivek Goyal
2012-01-30 14:59 ` [PATCH 2/2] floppy: Fix a crash during rmmod Vivek Goyal
2012-02-08 18:14 ` [PATCH 0/2] floppy: Fix couple of crashes during init and module removal Vivek Goyal
2012-02-08 19:03   ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).