Page MenuHomeFreeBSD

linuxkpi: Fix llist_entry
Needs ReviewPublic

Authored by manu on Aug 22 2022, 8:32 AM.
Referenced Files
F166905189: D36289.id109654.diff
Mon, Aug 17, 4:21 PM
Unknown Object (File)
Thu, Aug 13, 12:31 PM
Unknown Object (File)
Thu, Aug 13, 12:30 PM
Unknown Object (File)
Jul 7 2026, 6:52 PM
Unknown Object (File)
Jun 27 2026, 12:30 AM
Unknown Object (File)
Apr 21 2026, 5:43 AM
Unknown Object (File)
Apr 18 2026, 10:40 PM
Unknown Object (File)
Apr 12 2026, 4:56 PM

Details

Reviewers
None
Group Reviewers
linuxkpi
Summary

llist_entry(NULL) must not return NULL, it needs to wrap around
and return NULL minus the offset.

the iterators stop when the offset added back to the result of
llist_entry() is NULL

they test that the first node is not NULL or that the next pointer
stored in a previous iteration of the loop is not NULL

OpenBSD commit: https://cvsweb.openbsd.org/cgi-bin/cvsweb/src/sys/dev/pci/drm/include/linux/llist.h?rev=1.3&content-type=text/x-cvsweb-markup

Reported by: jsg@OpenBSD.org
Sponsored by: Beckhoff Automation GmbH & Co. KG

Diff Detail

Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

manu requested review of this revision.Aug 22 2022, 8:32 AM
hselasky added inline comments.
sys/compat/linuxkpi/common/include/linux/llist.h
91

Is it more clean to write:

(pos) != llist_entry(NULL, __typeof(*pos), member)
92

While at it change:

pos->member.next

into:

(pos)->member.next
97

Ditto?

sys/compat/linuxkpi/common/include/linux/llist.h
91

Why that ?
I find your way more confusing.

sys/compat/linuxkpi/common/include/linux/llist.h
91

Because container_of() is doing some type checking at least, while (char *) is a pure cast.

I don't have any strong opinion here.