Re: [PATCH 5/5] qla_target/tcm_qla2xxx: Convert to use target_put_session + sess_kref

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

 



On Mon, Feb 27, 2012 at 12:45 PM, Jörn Engel <joern@xxxxxxxxx> wrote:
>> +                     if (ha->tgt_ops->put_sess(sess) != 0)
>> +                             return;
>> +             spin_lock_irqsave(&ha->hardware_lock, flags);
>
> Can we get rid of the " != 0"?  It does not add anything logically an
> to me personally it actually makes the code harder to read.

I agree and in fact I think I agree with your bigger point -- it seems
almost impossible to use the return value of put_sess() in any safe
way, so we are better off never checking it (and having the method
be void).  The comment in kref.h certainly seems to apply:

 * Return 1 if the object was removed, otherwise return 0.  Beware, if this
 * function returns 0, you still can not count on the kref from remaining in
 * memory.  Only use the return value if you want to see if the kref is now
 * gone, not present.

so even if we don't drop the last reference in our put call, nothing
prevents another context from dropping the last reference immediately
after our call and blowing things up.

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


[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux