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)
Fri, Oct 25, 11:39 PM
Unknown Object (File)
Fri, Oct 25, 11:38 PM
Unknown Object (File)
Fri, Oct 25, 11:38 PM
Unknown Object (File)
Fri, Oct 25, 11:38 PM
Unknown Object (File)
Sep 30 2024, 4:11 PM
Unknown Object (File)
Sep 24 2024, 6:05 PM
Unknown Object (File)
Sep 21 2024, 10:30 AM
Unknown Object (File)
Sep 20 2024, 2:11 PM
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.