[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <5677F9F7.8060201@linux.intel.com>
Date: Mon, 21 Dec 2015 15:09:11 +0200
From: Mathias Nyman <mathias.nyman@...ux.intel.com>
To: Julia Lawall <julia.lawall@...6.fr>,
Geliang Tang <geliangtang@....com>
CC: Mathias Nyman <mathias.nyman@...el.com>,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-usb@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 5/9] usb: xhci: use list_for_each_entry
On 18.12.2015 20:30, Julia Lawall wrote:
> Geliang,
>
> Please check whether it is acceptable that last_unlinked_td point to the
> dummy entry at th beginning of the list, in the case where the
> list_for_each_entry loop runs out normally.
>
> It seems that you have sent a bunch of these patches. Please recheck them
> all to see if they really follow the semantics of list_for_each_entry
> properly. If particular, you should not normally use the index variable
> after leaving the loop, unless it is guaranteed that the exit from the
> loop was via a break.
>
Julia is correct, we can't use list_for_each_entry() here as cur_td would end up
pointing to list head, and we really need it to point to the last entry in the list at that point.
old:
- list_for_each(entry, &ep->cancelled_td_list) {
- cur_td = list_entry(entry, struct xhci_td, cancelled_td_list);
cur_td_will point to last element in list. "entry" will point to head, but is on longer used.
new:
+ list_for_each_entry(cur_td, &ep->cancelled_td_list, cancelled_td_list) {
cur_td will point to head of list.
This is important as newly canceled TDs can be added to the tail of the list while
looping through and returning the canceled TDs. We want to make sure we
only return and delete the TDs up to the point we have handled them on the ring.
(code continues with: last_unlinked_td = cur_td;)
Thanks Julia for spotting this
-Mathias
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists