lkml.org 
[lkml]   [2012]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] xhci: fix null-pointer dereference when destroying half-built segment rings
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


\
 
 \ /
  Last update: 2012-11-01 19:21    [W:0.079 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site