svn commit: r328654 - stable/11/sys/compat/linuxkpi/common/src
Hans Petter Selasky
hselasky at FreeBSD.org
Thu Feb 1 13:04:02 UTC 2018
Author: hselasky
Date: Thu Feb 1 13:04:01 2018
New Revision: 328654
URL: https://svnweb.freebsd.org/changeset/base/328654
Log:
MFC r328329:
Properly implement the "id" callback argument in the "idr_for_each" function
in the LinuxKPI. The old implementation assumed only one IDR layer was present.
Take additional IDR layers into account when computing the "id" value.
Found by: Karthik Palanichamy <karthikp at chelsio.com>
Tested by: Karthik Palanichamy <karthikp at chelsio.com>
Sponsored by: Mellanox Technologies
Modified:
stable/11/sys/compat/linuxkpi/common/src/linux_idr.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sys/compat/linuxkpi/common/src/linux_idr.c
==============================================================================
--- stable/11/sys/compat/linuxkpi/common/src/linux_idr.c Thu Feb 1 13:01:44 2018 (r328653)
+++ stable/11/sys/compat/linuxkpi/common/src/linux_idr.c Thu Feb 1 13:04:01 2018 (r328654)
@@ -680,7 +680,7 @@ idr_alloc_cyclic(struct idr *idr, void *ptr, int start
}
static int
-idr_for_each_layer(struct idr_layer *il, int layer,
+idr_for_each_layer(struct idr_layer *il, int offset, int layer,
int (*f)(int id, void *p, void *data), void *data)
{
int i, err;
@@ -691,7 +691,7 @@ idr_for_each_layer(struct idr_layer *il, int layer,
for (i = 0; i < IDR_SIZE; i++) {
if (il->ary[i] == NULL)
continue;
- err = f(i, il->ary[i], data);
+ err = f(i + offset, il->ary[i], data);
if (err)
return (err);
}
@@ -700,7 +700,8 @@ idr_for_each_layer(struct idr_layer *il, int layer,
for (i = 0; i < IDR_SIZE; i++) {
if (il->ary[i] == NULL)
continue;
- err = idr_for_each_layer(il->ary[i], layer - 1, f, data);
+ err = idr_for_each_layer(il->ary[i],
+ (i + offset) * IDR_SIZE, layer - 1, f, data);
if (err)
return (err);
}
@@ -711,7 +712,7 @@ idr_for_each_layer(struct idr_layer *il, int layer,
int
idr_for_each(struct idr *idp, int (*f)(int id, void *p, void *data), void *data)
{
- return (idr_for_each_layer(idp->top, idp->layers - 1, f, data));
+ return (idr_for_each_layer(idp->top, 0, idp->layers - 1, f, data));
}
int
More information about the svn-src-stable
mailing list