lkml.org 
[lkml]   [2007]   [Oct]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [bug] ata subsystem related crash with latest -git
    On Oct. 18, 2007, 15:32 +0200, Jens Axboe <jens.axboe@oracle.com> wrote:
    > static inline struct scatterlist *sg_next(struct scatterlist *sg)
    > {
    > - sg++;
    > -
    > - if (unlikely(sg_is_chain(sg)))
    > +#ifdef CONFIG_DEBUG_SG
    > + BUG_ON(sg->sg_magic != SG_MAGIC);
    > +#endif
    > + if (sg_is_last(sg))
    > + sg = NULL;
    > + else if (sg_is_chain(sg))
    > sg = sg_chain_ptr(sg);
    > + else
    > + sg++;
    >

    Jens, again, please correct me if I'm wrong, but when sg points at the
    entry right before a chain entry this implementation of sg_next will
    return a pointer to the chain entry here, which I believe it must not.

    > return sg;
    > }
    >

    here's how I think sg_next should be implemented:

    */
    static inline struct scatterlist *sg_next(struct scatterlist *sg)
    {
    +#ifdef CONFIG_DEBUG_SG
    + BUG_ON(sg->sg_magic != SG_MAGIC);
    +#endif
    + if (sg_is_last(sg))
    + return NULL;
    +
    sg++;

    if (unlikely(sg_is_chain(sg)))
    sg = sg_chain_ptr(sg);

    return sg;
    }
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

    \
     
     \ /
      Last update: 2007-10-18 15:53    [W:0.023 / U:58.708 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site