Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 21 Jun 2012 12:51:41 +0300
From:      Alexander Motin <mav@FreeBSD.org>
To:        Sergey Kandaurov <pluknet@freebsd.org>
Cc:        svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org, Oliver Fromme <olli@lurza.secnetix.de>
Subject:   Re: svn commit: r237335 - head/sys/cam/scsi
Message-ID:  <4FE2EEAD.3070706@FreeBSD.org>
In-Reply-To: <CAE-mSOJ6YV0f=NH%2BH4_rbrawOzG8_HcVqtwL%2Br0MVj9L64PN0g@mail.gmail.com>
References:  <201206201825.q5KIPpjQ060916@svn.freebsd.org> <CAE-mSOJ6YV0f=NH%2BH4_rbrawOzG8_HcVqtwL%2Br0MVj9L64PN0g@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On 06/21/12 12:30, Sergey Kandaurov wrote:
> On 20 June 2012 22:25, Alexander Motin<mav@freebsd.org>  wrote:
>> Author: mav
>> Date: Wed Jun 20 18:25:51 2012
>> New Revision: 237335
>> URL: http://svn.freebsd.org/changeset/base/237335
>>
>> Log:
>>   Check status of cam_periph_hold() inside cdclose().  If cd device was
>>   invalidated while open, cam_periph_hold() will return error and won't
>>   get the reference.  Following reference release will crash the system.
>>
>>   Sponsored by: iXsystems, Inc.
>>   MFC after:    3 days
>>
>> Modified:
>>   head/sys/cam/scsi/scsi_cd.c
>>
>> Modified: head/sys/cam/scsi/scsi_cd.c
>> ==============================================================================
>> --- head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:00:26 2012        (r237334)
>> +++ head/sys/cam/scsi/scsi_cd.c Wed Jun 20 18:25:51 2012        (r237335)
>> @@ -1041,6 +1041,7 @@ cdclose(struct disk *dp)
>>   {
>>         struct  cam_periph *periph;
>>         struct  cd_softc *softc;
>> +       int error;
>>
>>         periph = (struct cam_periph *)dp->d_drv1;
>>         if (periph == NULL)
>> @@ -1049,7 +1050,11 @@ cdclose(struct disk *dp)
>>         softc = (struct cd_softc *)periph->softc;
>>
>>         cam_periph_lock(periph);
>> -       cam_periph_hold(periph, PRIBIO);
>> +       if ((error = cam_periph_hold(periph, PRIBIO)) != 0) {
>> +               cam_periph_unlock(periph);
>> +               cam_periph_release(periph);
>> +               return (0);
>> +       }
>>
>>         CAM_DEBUG(periph->path, CAM_DEBUG_TRACE | CAM_DEBUG_PERIPH,
>>             ("cdclose\n"));
>
> Does it fix the reported crash with cd refcount underflow? It seems so.
> http://lists.freebsd.org/pipermail/freebsd-stable/2012-June/068175.html

Yes, I think it should. At least diagnostics looks very alike.

-- 
Alexander Motin



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4FE2EEAD.3070706>