Date: Thu, 1 Feb 2018 13:04:01 +0000 (UTC) From: Hans Petter Selasky <hselasky@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r328654 - stable/11/sys/compat/linuxkpi/common/src Message-ID: <201802011304.w11D41sr009994@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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@chelsio.com> Tested by: Karthik Palanichamy <karthikp@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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201802011304.w11D41sr009994>