Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: xiaolinkui <xiaolinkui@126.com>
To: dennis.dalessandro@cornelisnetworks.com, jgg@ziepe.ca, leon@kernel.org
Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org,
	Linkui Xiao <xiaolinkui@kylinos.cn>
Subject: [PATCH] RDMA/hfi: add a judgment on the availability of cpumask
Date: Tue,  4 Apr 2023 11:05:25 +0800	[thread overview]
Message-ID: <20230404030525.24020-1-xiaolinkui@126.com> (raw)

From: Linkui Xiao <xiaolinkui@kylinos.cn>

When CONFIG_CPUMASK_OFFSTACK is n, cpumask may fail to allocate, cpumask may
be NULL, and performing a bitmap operation on cpumask may cause problems at
this time.

Of course, this is a unlikely event.

Signed-off-by: Linkui Xiao <xiaolinkui@kylinos.cn>
---
 drivers/infiniband/hw/hfi1/affinity.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/infiniband/hw/hfi1/affinity.c b/drivers/infiniband/hw/hfi1/affinity.c
index 77ee77d4000f..3caa861f4d1d 100644
--- a/drivers/infiniband/hw/hfi1/affinity.c
+++ b/drivers/infiniband/hw/hfi1/affinity.c
@@ -1047,16 +1047,16 @@ int hfi1_get_proc_affinity(int node)
 	 */
 
 	ret = zalloc_cpumask_var(&diff, GFP_KERNEL);
-	if (!ret)
+	if (!ret || unlikely(!diff))
 		goto done;
 	ret = zalloc_cpumask_var(&hw_thread_mask, GFP_KERNEL);
-	if (!ret)
+	if (!ret || unlikely(!hw_thread_mask))
 		goto free_diff;
 	ret = zalloc_cpumask_var(&available_mask, GFP_KERNEL);
-	if (!ret)
+	if (!ret || unlikely(!available_mask))
 		goto free_hw_thread_mask;
 	ret = zalloc_cpumask_var(&intrs_mask, GFP_KERNEL);
-	if (!ret)
+	if (!ret || unlikely(!intrs_mask))
 		goto free_available_mask;
 
 	mutex_lock(&affinity->lock);
-- 
2.17.1


             reply	other threads:[~2023-04-04  3:37 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-04  3:05 xiaolinkui [this message]
2023-04-04  6:05 ` [PATCH] RDMA/hfi: add a judgment on the availability of cpumask Leon Romanovsky
2023-04-04  7:01   ` xiaolinkui
2023-04-04  8:02     ` Leon Romanovsky
2023-04-07  4:07 ` kernel test robot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230404030525.24020-1-xiaolinkui@126.com \
    --to=xiaolinkui@126.com \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=jgg@ziepe.ca \
    --cc=leon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=xiaolinkui@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox