Re: [PATCH] PPC64 Fix unbalanced pci_dev_put in EEH code

From: Linas Vepstas
Date: Thu Aug 19 2004 - 17:58:16 EST


On Thu, Aug 19, 2004 at 11:04:14AM +1000, Paul Mackerras was heard to remark:
> Linas Vepstas writes:
>
> > Hang on there, you didn't just rename the variable, you also missed a
> > teeny chunk of the original patch. The corrected path is attached below.
> > (Well, I rather liked my original var names better, but whatever).
>
> Look closer, I didn't miss the chunk, I solved the race condition that
> you mentioned. :) I did if (!inserted) pci_dev_put(dev) at the end
> rather than if (inserted) pci_dev_get(dev).

OK, I missed the ! (which is why I like !=0 because that avoids
single-char errors from ruinging things.)

That will work.

There's no race, since the for-each-device loop performs a pci_dev_get
which holds on to the device for the duration of the loop interior.
So doing a dev_get at any time inside the loop is sufficient; no
ordering is required.

(One of my original errors was assuming that I had to do a dev_put at the
bottom of the loop to counteract the for-each-device's get; but, no,
this is not needed, the for-each-device loop performs a dev-put at
the end of the loop, just as it does a dev_get for the next iteration.)

--linas
-
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/