[lustre-devel] [PATCH 30/40] lnet: memory leak in copy_ioc_udsp_descr
James Simmons <[email protected]> Sun, 9 Apr 2023 08:13:10 -0400
| Newsgroups | org.lustre.lists.lustre-devel |
|---|---|
| Message-ID | <[email protected]> |
From: Chris Horn <[email protected]> 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 <[email protected]> Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50081 Reviewed-by: Serguei Smirnov <[email protected]> Reviewed-by: Frank Sehr <[email protected]> Reviewed-by: Cyril Bordage <[email protected]> Reviewed-by: Oleg Drokin <[email protected]> Signed-off-by: James Simmons <[email protected]> --- 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 _______________________________________________ lustre-devel mailing list [email protected] http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org