Page MenuHomeFreeBSD

ib mad: fix an incorrect use of list_for_each_entry
ClosedPublic

Authored by markj on Jul 30 2015, 12:29 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Oct 8, 4:40 AM
Unknown Object (File)
Mon, Oct 6, 9:05 PM
Unknown Object (File)
Mon, Oct 6, 5:26 PM
Unknown Object (File)
Mon, Oct 6, 8:50 AM
Unknown Object (File)
Mon, Oct 6, 4:16 AM
Unknown Object (File)
Sun, Oct 5, 7:53 AM
Unknown Object (File)
Sun, Oct 5, 7:49 AM
Unknown Object (File)
Sun, Oct 5, 7:48 AM
Subscribers

Details

Summary

In tf_dequeue(), if we reach the end of the fifo list without finding a
non-cancelled element, tmp will be a pointer to the list head, so the
tmp->canceled check is bogus. Use a flag instead to avoid this.

Submitted by: Tao Liu <Tao.Liu@isilon.com>

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

markj retitled this revision from to ib mad: fix an incorrect use of list_for_each_entry.
markj edited the test plan for this revision. (Show Details)
markj added a reviewer: hselasky.
markj updated this object.
sys/ofed/drivers/infiniband/core/mad.c
307 ↗(On Diff #7491)

I think the correct fix is:

if (tmp == NULL)
....

No need for an extra variable?

You can assume that at the end of list_for_each_entry() "tmp" is NULL.

--HPS

sys/ofed/drivers/infiniband/core/mad.c
307 ↗(On Diff #7491)

That's true with queue(9) but not with Linux's list macros. Otherwise we'd always crash here.

sys/ofed/drivers/infiniband/core/mad.c
307 ↗(On Diff #7491)

I was mixing list_for_each() with list_for_each_safe() ... Would it be an idea to switch to list_for_each_safe() ? And add a list entry pointer instead of a bool. It will consume a register anyway ...

sys/ofed/drivers/infiniband/core/mad.c
307 ↗(On Diff #7491)

Nevermind. You're right Linux lists are not queue(9) compatible.

This revision is now accepted and ready to land.Jul 30 2015, 7:51 AM
sys/ofed/drivers/infiniband/core/mad.c
307 ↗(On Diff #7491)

Don't forget to MFC when you commit it.

This revision was automatically updated to reflect the committed changes.