From: Stanislaw Gruszka <stf_xl@wp.pl>
To: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Cc: linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org
Subject: Re: Bad module reference counter
Date: Wed, 25 Feb 2009 12:00:42 +0100 [thread overview]
Message-ID: <200902251200.42517.stf_xl@wp.pl> (raw)
In-Reply-To: <200902232336.35371.bzolnier@gmail.com>
Monday 23 February 2009 23:36:35 Bartlomiej Zolnierkiewicz napisał(a):
> > Looks that using ->dev insted of ->kref will do the work. But perhaps less
> > intrusive fix, like check kref in ide_disk_put() would be better solution.
> > I tested below patch and everythings is fine.
> >
> > diff --git a/drivers/ide/ide-gd.c b/drivers/ide/ide-gd.c
> > index 7857b20..598f21b 100644
> > --- a/drivers/ide/ide-gd.c
> > +++ b/drivers/ide/ide-gd.c
> > @@ -48,8 +48,8 @@ static void ide_disk_put(struct ide_disk_obj *idkp)
> > ide_drive_t *drive = idkp->drive;
> >
> > mutex_lock(&ide_disk_ref_mutex);
> > - kref_put(&idkp->kref, ide_disk_release);
> > - ide_device_put(drive);
> > + if (!kref_put(&idkp->kref, ide_disk_release))
> > + ide_device_put(drive);
>
> I worry that this just masks the problem as according to your previous
> mail drive still can be already gone before ->flush in ide_gd_remove().
I checked my patch against all mentioned problems, but it doesn't matter now.
> > mutex_unlock(&ide_disk_ref_mutex);
> > }
> >
> > If this patch is ok and dropping kref to dev is not planed currently, maybe
> > I'll send "official" patch with ide-gd fix and for other devices types.
>
> Lets fix it fully. The below patch together with previous ide_device_put()
> fix and drive_release_dev() one (from another mail) should make all problems
> go away...
>
> From: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
> Subject: [PATCH] ide: fix refcounting in device drivers
>
> During host driver module removal del_gendisk() results in a final
> put on drive->gendev and freeing the drive by drive_release_dev().
>
> Convert device drivers from using struct kref to use struct device
> so device driver's object holds reference on ->gendev and prevents
> drive from prematurely going away.
>
> Also fix ->remove methods to not erroneously drop reference on a
> host driver by using only put_device() instead of ide*_put().
>
> Reported-by: Stanislaw Gruszka <stf_xl@wp.pl>
> Signed-off-by: Bartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Tested-by: Stanislaw Gruszka <stf_xl@wp.pl>
prev parent reply other threads:[~2009-02-25 11:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <200902111032.59225.stf_xl@wp.pl>
[not found] ` <200902182225.19784.bzolnier@gmail.com>
2009-02-19 12:48 ` Bad module reference counter Stanislaw Gruszka
2009-02-19 16:49 ` Bartlomiej Zolnierkiewicz
2009-02-20 10:45 ` Stanislaw Gruszka
2009-02-23 22:36 ` Bartlomiej Zolnierkiewicz
2009-02-25 11:00 ` Stanislaw Gruszka [this message]
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=200902251200.42517.stf_xl@wp.pl \
--to=stf_xl@wp.pl \
--cc=bzolnier@gmail.com \
--cc=linux-ide@vger.kernel.org \
--cc=linux-scsi@vger.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox