1 Star 0 Fork 45

chenke/rdma-core

forked from src-openEuler/rdma-core 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0034-librdmacm-Fix-an-overflow-bug-in-qsort-comparison-function.patch 1.25 KB
一键复制 编辑 原始数据 按行查看 历史
From c4a5ac8bba611206e062c0955fb605bfc0f48b0f Mon Sep 17 00:00:00 2001
From: Mark Zhang <markzhang@nvidia.com>
Date: Fri, 26 Apr 2024 14:17:55 +0300
Subject: [PATCH] librdmacm: Fix an overflow bug in qsort comparison function
Reference: https://github.com/linux-rdma/rdma-core/commit/c4a5ac8bba611206e062c0955fb605bfc0f48b0f
The comparison function dev_cmp() doesn't work with 64b pointers in some
cases, as it casts the pointer to int. For example it's not able to sort
this list:
{0xfffe0c2f0b00, 0xaaac741b4a90, 0xaaac741b4d70}
Fixes: e5d371cb0af0 ("librdmacm: Globally store and sort IB device list")
Signed-off-by: Mark Zhang <markzhang@nvidia.com>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: Yishai Hadas <yishaih@nvidia.com>
---
librdmacm/cma.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/librdmacm/cma.c b/librdmacm/cma.c
index 7b924bd..0a631bd 100644
--- a/librdmacm/cma.c
+++ b/librdmacm/cma.c
@@ -311,7 +311,7 @@ static void remove_cma_dev(struct cma_device *cma_dev)
static int dev_cmp(const void *a, const void *b)
{
- return (int)(*(char *const *)a - *(char *const *)b);
+ return (*(uintptr_t *)a > *(uintptr_t *)b) - (*(uintptr_t *)a < *(uintptr_t *)b);
}
static int sync_devices_list(void)
--
2.27.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/chenke1978/rdma-core.git
git@gitee.com:chenke1978/rdma-core.git
chenke1978
rdma-core
rdma-core
master

搜索帮助