Re: [PATCH] RDMA/hns: fix dead empty check on head->root in setup_root_hem()
From: Jason Gunthorpe
Date: Mon May 25 2026 - 11:52:15 EST
On Thu, May 21, 2026 at 09:20:45PM +0800, Maoyi Xie wrote:
> --- a/drivers/infiniband/hw/hns/hns_roce_hem.c
> +++ b/drivers/infiniband/hw/hns/hns_roce_hem.c
> @@ -1267,8 +1267,8 @@ setup_root_hem(struct hns_roce_dev *hr_dev, struct hns_roce_hem_list *hem_list,
> int i, total;
> int ret;
>
> - root_hem = list_first_entry(&head->root,
> - struct hns_roce_hem_item, list);
> + root_hem = list_first_entry_or_null(&head->root,
> + struct hns_roce_hem_item, list);
> if (!root_hem)
> return -ENOMEM;
Delete the if, the list can never be empty. The driver immediately
adds an entry after initializing it and never removes entries
Jason