[lustre-devel] [PATCH 30/40] lnet: memory leak in copy_ioc_udsp_descr
James Simmons
jsimmons at infradead.org
Sun Apr 9 05:13:10 PDT 2023
From: Chris Horn <chris.horn at hpe.com>
copy_ioc_udsp_descr() doesn't correctly handle the case where a
net number was not specified. In this case, there isn't any net
number range that needs to be copied into the udsp descriptor.
WC-bug-id: https://jira.whamcloud.com/browse/LU-16575
Lustre-commit: f8e129198b002589d ("LU-16575 lnet: memory leak in copy_ioc_udsp_descr")
Signed-off-by: Chris Horn <chris.horn at hpe.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50081
Reviewed-by: Serguei Smirnov <ssmirnov at whamcloud.com>
Reviewed-by: Frank Sehr <fsehr at whamcloud.com>
Reviewed-by: Cyril Bordage <cbordage at whamcloud.com>
Reviewed-by: Oleg Drokin <green at whamcloud.com>
Signed-off-by: James Simmons <jsimmons at infradead.org>
---
net/lnet/lnet/udsp.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/net/lnet/lnet/udsp.c b/net/lnet/lnet/udsp.c
index 2594df1..deaca51 100644
--- a/net/lnet/lnet/udsp.c
+++ b/net/lnet/lnet/udsp.c
@@ -1485,8 +1485,19 @@ struct lnet_udsp *
CDEBUG(D_NET, "%u\n", nid_descr->ud_net_id.udn_net_type);
/* allocate the total memory required to copy this NID descriptor */
- alloc_size = (sizeof(struct cfs_expr_list) * (expr_count + 1)) +
- (sizeof(struct cfs_range_expr) * (range_count));
+ if (ioc_nid->iud_net.ud_net_num_expr.le_count) {
+ if (ioc_nid->iud_net.ud_net_num_expr.le_count != 1) {
+ CERROR("Unexpected number of net numeric ranges \"%u\". Cannot add UDSP rule.\n",
+ ioc_nid->iud_net.ud_net_num_expr.le_count);
+ return -EINVAL;
+ }
+ alloc_size = (sizeof(struct cfs_expr_list) * (expr_count + 1)) +
+ (sizeof(struct cfs_range_expr) * (range_count));
+ } else {
+ alloc_size = (sizeof(struct cfs_expr_list) * (expr_count)) +
+ (sizeof(struct cfs_range_expr) * (range_count));
+ }
+
buf = kzalloc(alloc_size, GFP_KERNEL);
if (!buf)
return -ENOMEM;
--
1.8.3.1
More information about the lustre-devel
mailing list