]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
Fix termination state for idr_for_each_entry_ul()
authorNeilBrown <neilb@suse.de>
Mon, 23 Oct 2023 22:53:33 +0000 (09:53 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 20 Nov 2023 09:30:15 +0000 (10:30 +0100)
commit85513df59a3eeeaf12c92350c90bb82ffdd4d104
tree86f3fd0700f0140dde83cd7f283ecac3ff652dc4
parent56cddb5e657f0e935cf5e47b781717ce97647c57
Fix termination state for idr_for_each_entry_ul()

[ Upstream commit e8ae8ad479e2d037daa33756e5e72850a7bd37a9 ]

The comment for idr_for_each_entry_ul() states

  after normal termination @entry is left with the value NULL

This is not correct in the case where UINT_MAX has an entry in the idr.
In that case @entry will be non-NULL after termination.
No current code depends on the documentation being correct, but to
save future code we should fix it.

Also fix idr_for_each_entry_continue_ul().  While this is not documented
as leaving @entry as NULL, the mellanox driver appears to depend on
it doing so.  So make that explicit in the documentation as well as in
the code.

Fixes: e33d2b74d805 ("idr: fix overflow case for idr_for_each_entry_ul()")
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Chris Mi <chrism@mellanox.com>
Cc: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/linux/idr.h