Re: [PATCH] mm/backing-dev.c: fix crash when USB/SCSI device isdetached

From: Wu Fengguang
Date: Mon Jan 16 2012 - 00:53:55 EST


On Mon, Jan 16, 2012 at 01:50:44PM +0800, Wu Fengguang wrote:
> On Mon, Jan 16, 2012 at 02:28:30PM +0900, Chanho Min wrote:
> > On Mon, Jan 16, 2012 at 11:53 AM, Wu Fengguang <fengguang.wu@xxxxxxxxx> wrote:
> > > On Sun, Jan 15, 2012 at 09:11:07PM +0530, Rabin Vincent wrote:
> > >> On Sun, Jan 15, 2012 at 08:58:53PM +0800, Wu Fengguang wrote:
> > >> > On Sun, Jan 15, 2012 at 03:58:43PM +0530, Rabin Vincent wrote:
> > >> > > diff --git a/mm/backing-dev.c b/mm/backing-dev.c
> > >> > > index 71034f4..a39ad70 100644
> > >> > > --- a/mm/backing-dev.c
> > >> > > +++ b/mm/backing-dev.c
> > >> > > @@ -318,7 +318,7 @@ static void wakeup_timer_fn(unsigned long data)
> > >> > > Â if (bdi->wb.task) {
> > >> > > Â Â Â Â Â trace_writeback_wake_thread(bdi);
> > >> > > Â Â Â Â Â wake_up_process(bdi->wb.task);
> > >> > > - } else {
> > >> > > + } else if (bdi->dev) {
> > >> > > Â Â Â Â Â /*
> > >> > > Â Â Â Â Â Â* When bdi tasks are inactive for long time, they are killed.
> > >> > > Â Â Â Â Â Â* In this case we have to wake-up the forker thread which
> > >> > > @@ -584,6 +584,8 @@ EXPORT_SYMBOL(bdi_register_dev);
> > >> > > Â */
> > >> > > Âstatic void bdi_wb_shutdown(struct backing_dev_info *bdi)
> > >> > > Â{
> > >> > > + struct task_struct *task = NULL;
> >
> > Thanks, I fully understand.
> > In addition, Would not bdi_wakeup_flusher also be fixed?
>
> Yes, indeed!

But wait.. Rabin's patch actually fixes the NULL deference in
the call

trace_writeback_wake_forker_thread(bdi);

The wakeup of the forker thread should be harmless.

Thanks,
Fengguang

> > >From dc7d4e86911c0a7ea35043485b04e8a09aa74ffd Mon Sep 17 00:00:00 2001
> > From: Chanho Min <chanho.min@xxxxxxx>
> > Date: Mon, 16 Jan 2012 14:14:48 +0900
> > Subject: [PATCH] backing-dev: add for 'fix wakeup timer races with
> > bdi_unregister()'
> >
> > Signed-off-by: Chanho Min <chanho.min@xxxxxxx>
> > ---
> > fs/fs-writeback.c | 2 +-
> > 1 files changed, 1 insertions(+), 1 deletions(-)
> >
> > diff --git a/fs/fs-writeback.c b/fs/fs-writeback.c
> > index f855916..ee40833 100644
> > --- a/fs/fs-writeback.c
> > +++ b/fs/fs-writeback.c
> > @@ -97,7 +97,7 @@ static void bdi_wakeup_flusher(struct backing_dev_info *bdi)
> > {
> > if (bdi->wb.task) {
> > wake_up_process(bdi->wb.task);
> > - } else {
> > + } else if (bdi->dev) {
> > /*
> > * The bdi thread isn't there, wake up the forker thread which
> > * will create and run it.
> > --
> > 1.7.0.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/