devlink: drop the filter argument from devlinks_xa_find_get

commit 8861c0933c78e3631fe752feadc0d2a6e5eab1e1 upstream.

Looks like devlinks_xa_find_get() was intended to get the mark
from the @filter argument. It doesn't actually use @filter, passing
DEVLINK_REGISTERED to xa_find_fn() directly. Walking marks other
than registered is unlikely so drop @filter argument completely.

Reviewed-by: Jiri Pirko <jiri@nvidia.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Ido: Moved the changes from core.c and devl_internal.h to leftover.c ]
Stable-dep-of: d77278196441 ("devlink: bump the instance index directly when iterating")
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Jakub Kicinski 2023-01-04 20:05:24 -08:00 committed by Greg Kroah-Hartman
parent 6ec0fe3756
commit 031f06fd75

View File

@ -289,7 +289,7 @@ void devl_unlock(struct devlink *devlink)
EXPORT_SYMBOL_GPL(devl_unlock);
static struct devlink *
devlinks_xa_find_get(struct net *net, unsigned long *indexp, xa_mark_t filter,
devlinks_xa_find_get(struct net *net, unsigned long *indexp,
void * (*xa_find_fn)(struct xarray *, unsigned long *,
unsigned long, xa_mark_t))
{
@ -322,30 +322,25 @@ unlock:
}
static struct devlink *devlinks_xa_find_get_first(struct net *net,
unsigned long *indexp,
xa_mark_t filter)
unsigned long *indexp)
{
return devlinks_xa_find_get(net, indexp, filter, xa_find);
return devlinks_xa_find_get(net, indexp, xa_find);
}
static struct devlink *devlinks_xa_find_get_next(struct net *net,
unsigned long *indexp,
xa_mark_t filter)
unsigned long *indexp)
{
return devlinks_xa_find_get(net, indexp, filter, xa_find_after);
return devlinks_xa_find_get(net, indexp, xa_find_after);
}
/* Iterate over devlink pointers which were possible to get reference to.
* devlink_put() needs to be called for each iterated devlink pointer
* in loop body in order to release the reference.
*/
#define devlinks_xa_for_each_get(net, index, devlink, filter) \
for (index = 0, \
devlink = devlinks_xa_find_get_first(net, &index, filter); \
devlink; devlink = devlinks_xa_find_get_next(net, &index, filter))
#define devlinks_xa_for_each_registered_get(net, index, devlink) \
devlinks_xa_for_each_get(net, index, devlink, DEVLINK_REGISTERED)
for (index = 0, \
devlink = devlinks_xa_find_get_first(net, &index); \
devlink; devlink = devlinks_xa_find_get_next(net, &index))
static struct devlink *devlink_get_from_attrs(struct net *net,
struct nlattr **attrs)