Commit 911a81c9 authored by wangyugui's avatar wangyugui Committed by Jason Gunthorpe

RDMA/core: Use kvzalloc when allocating the struct ib_port

The 'struct attribute' flex array contains some struct lock_class_key's
which become big when lockdep is turned on. Big enough that some drivers
will not load when CONFIG_PROVE_LOCKING=y because they cannot allocate
enough memory:

 WARNING: CPU: 36 PID: 8 at mm/page_alloc.c:5350 __alloc_pages+0x27e/0x3e0
  Call Trace:
   kmalloc_order+0x2a/0xb0
   kmalloc_order_trace+0x19/0xf0
   __kmalloc+0x231/0x270
   ib_setup_port_attrs+0xd8/0x870 [ib_core]
   ib_register_device+0x419/0x4e0 [ib_core]
   bnxt_re_task+0x208/0x2d0 [bnxt_re]

Link: https://lore.kernel.org/r/20211019002656.17745-1-wangyugui@e16-tech.comSigned-off-by: default avatarwangyugui <wangyugui@e16-tech.com>
Signed-off-by: default avatarJason Gunthorpe <jgg@nvidia.com>
parent dede33da
...@@ -757,7 +757,7 @@ static void ib_port_release(struct kobject *kobj) ...@@ -757,7 +757,7 @@ static void ib_port_release(struct kobject *kobj)
if (port->hw_stats_data) if (port->hw_stats_data)
rdma_free_hw_stats_struct(port->hw_stats_data->stats); rdma_free_hw_stats_struct(port->hw_stats_data->stats);
kfree(port->hw_stats_data); kfree(port->hw_stats_data);
kfree(port); kvfree(port);
} }
static void ib_port_gid_attr_release(struct kobject *kobj) static void ib_port_gid_attr_release(struct kobject *kobj)
...@@ -1205,7 +1205,7 @@ static struct ib_port *setup_port(struct ib_core_device *coredev, int port_num, ...@@ -1205,7 +1205,7 @@ static struct ib_port *setup_port(struct ib_core_device *coredev, int port_num,
struct ib_port *p; struct ib_port *p;
int ret; int ret;
p = kzalloc(struct_size(p, attrs_list, p = kvzalloc(struct_size(p, attrs_list,
attr->gid_tbl_len + attr->pkey_tbl_len), attr->gid_tbl_len + attr->pkey_tbl_len),
GFP_KERNEL); GFP_KERNEL);
if (!p) if (!p)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment