Re: [PATCH] xhci: fix null-pointer dereference when destroyinghalf-built segment rings

From: Sarah Sharp
Date: Thu Nov 01 2012 - 13:52:09 EST


On Mon, Oct 29, 2012 at 09:35:15PM +0300, Sergei Shtylyov wrote:
> Hello.
>
> On 10/29/2012 08:00 PM, Julius Werner wrote:
> > next = xhci_segment_alloc(xhci, cycle_state, flags);
> > if (!next) {
> > - xhci_free_segments_for_ring(xhci, *first);
> > + prev = *first;
> > + do {
> > + next = prev->next;
> > + xhci_segment_free(xhci, prev);
> > + } while ((prev = next));
>
> It's preferred that the assignments are done outside the *if* and *while*
> statements. In fact, at least for the *if* statements scripts/checkpatch.pl
> gives a warning (it was silent in this case).

Hi Julius,

I agree with Sergei (for once). The assignment in the while conditional
is confusing, and everyone reading the code will wonder if you meant
(prev == next). Putting extra parenthesis around it to avoid static
type checker warnings is kind of missing the point.

Your patch does apply fine with git-am, so don't worry about the line
endings. Can you please move the assignment into the loop and resubmit
this patch?

Sarah Sharp
--
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/