Re: [PATCH] [SCSI] hpsa: fix return value check in start_controller_lockup_detector()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, 2013-10-29 at 11:09 -0500, scameron@xxxxxxxxxxxxxxxxxx wrote:
> On Tue, Oct 29, 2013 at 02:43:56PM +0800, Wei Yongjun wrote:
> > From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> > 
> > In case of error, the function kthread_run() returns ERR_PTR()
> > and never returns NULL. The NULL test in the return value check
> > should be replaced with IS_ERR().
> > 
> > Signed-off-by: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
> > ---
> >  drivers/scsi/hpsa.c | 3 ++-
> >  1 file changed, 2 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c
> > index 891c86b..f413b14 100644
> > --- a/drivers/scsi/hpsa.c
> > +++ b/drivers/scsi/hpsa.c
> > @@ -4757,7 +4757,8 @@ static void start_controller_lockup_detector(struct ctlr_info *h)
> >  			kthread_run(detect_controller_lockup_thread,
> >  						NULL, HPSA);
> >  	}
> > -	if (!hpsa_lockup_detector) {
> > +	if (IS_ERR(hpsa_lockup_detector)) {
> > +		hpsa_lockup_detector = NULL;
> >  		dev_warn(&h->pdev->dev,
> >  			"Could not start lockup detector thread\n");
> >  		return;
> 
> Ack.

Hmm, this whole lockup thread start/stop thing is horribly racy with
hotplug (and bind and unbind).

Firstly, why do you need an actual thread, why not just use a workqueue?
That way you don't need a list or a lock, you can just schedule work for
each instance?  since they don't interfere, no global list and no lock.

If you insist on a thread, it should probably start at module insertion
and be shut down at module removal, so no races.  You can have it sleep
forever on list_empty(&hpsa_ctlr_list) and wake it when you add a
controller.

James


--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [SCSI Target Devel]     [Linux SCSI Target Infrastructure]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Samba]     [Device Mapper]
  Powered by Linux