Skip to contentSkip to conversation

contrib/rdmacm-mux: Fix error condition in hash_tbl_search_fd_by_ifid()

PATCH In review AlexChen 3 participants 7 messages Oct 29, 2020 – Nov 30, 2020

lore
Share & tools
lore

AlexChen

author
#0 lore raw

PATCH 1/1 contrib/rdmacm-mux: Fix error condition in hash_tbl_search_fd_by_ifid()

When fd is not found according to ifid, the _hash_tbl_search_fd_by_ifid() returns 0 and assigns the result to *fd, so We have to check that *fd is 0, not that fd is 0.

---
 contrib/rdmacm-mux/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/rdmacm-mux/main.c +1 -1
index bd82abbad3..771ca01e03 100644
@@ -186,7 +186,7 @@ static int hash_tbl_search_fd_by_ifid(int *fd, __be64 *gid_ifid)
     *fd = _hash_tbl_search_fd_by_ifid(gid_ifid);
     pthread_rwlock_unlock(&server.lock);
 
-    if (!fd) {
+    if (!*fd) {
         syslog(LOG_WARNING, "Can't find matching for ifid 0x%llx\n", *gid_ifid);
         return -ENOENT;
     }
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw

Hi Alex,

Quoted 25 lines · AlexChen

When fd is not found according to ifid, the _hash_tbl_search_fd_by_ifid() returns 0 and assigns the result to *fd, so We have to check that *fd is 0, not that fd is 0.

---
 contrib/rdmacm-mux/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
contrib/rdmacm-mux/main.c +1 -1
index bd82abbad3..771ca01e03 100644
@@ -186,7 +186,7 @@ static int hash_tbl_search_fd_by_ifid(int *fd, __be64
 *gid_ifid)
     *fd = _hash_tbl_search_fd_by_ifid(gid_ifid);
     pthread_rwlock_unlock(&server.lock);
 
-    if (!fd) {
+    if (!*fd) {
         syslog(LOG_WARNING, "Can't find matching for ifid 0x%llx\n",
 *gid_ifid);
         return -ENOENT;
     }
Quoted 4 lines

--
2.19.1

Thanks for the fix,
Marcel

author
#2 lore raw

Hi everyone,

Who can help me merge this patch into the master branch? This patch may be need for qemu-5.2

Thanks,
Alex

Quoted 37 lines · Marcel Apfelbaum

Hi Alex,

On Thu, Oct 29, 2020 at 3:43 PM AlexChen <[email protected] <mailto:[email protected]>> wrote:

    When fd is not found according to ifid, the _hash_tbl_search_fd_by_ifid()
    returns 0 and assigns the result to *fd, so We have to check that *fd is 0,
    not that fd is 0.

    Reported-by: Euler Robot <[email protected] <mailto:[email protected]>>
    Signed-off-by: AlexChen <[email protected] <mailto:[email protected]>>
    ---
     contrib/rdmacm-mux/main.c | 2 +-
     1 file changed, 1 insertion(+), 1 deletion(-)

    diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c
    index bd82abbad3..771ca01e03 100644
    --- a/contrib/rdmacm-mux/main.c
    +++ b/contrib/rdmacm-mux/main.c
    @@ -186,7 +186,7 @@ static int hash_tbl_search_fd_by_ifid(int *fd, __be64 *gid_ifid)
         *fd = _hash_tbl_search_fd_by_ifid(gid_ifid);
         pthread_rwlock_unlock(&server.lock);

    -    if (!fd) {
    +    if (!*fd) {
             syslog(LOG_WARNING, "Can't find matching for ifid 0x%llx\n", *gid_ifid);
             return -ENOENT;
         }
    -- 
    2.19.1
Reviewed-by Marcel Apfelbaum <[email protected] <mailto:[email protected]>>

Thanks for the fix,
Marcel

#3 lore raw
Quoted 4 lines · Alex Chen

Hi everyone,

Who can help me merge this patch into the master branch? This patch may be need for qemu-5.2

This code has been like this since 2018, so this is not a regression in 5.2. At this point in the release cycle (rc3 imminent) I think it's best to just leave it until 6.0.

thanks
-- PMM

author
#4 lore raw
Quoted 10 lines · Peter Maydell
Quoted 4 lines · Alex Chen

Hi everyone,

Who can help me merge this patch into the master branch? This patch may be need for qemu-5.2

This code has been like this since 2018, so this is not a regression in 5.2. At this point in the release cycle (rc3 imminent) I think it's best to just leave it until 6.0.

OK, I see.

Thanks
Alex

#5 lore raw

Hi Alex,

Quoted 6 lines · Alex Chen
Quoted 5 lines · Peter Maydell
Quoted 4 lines · Alex Chen

Hi everyone,

Who can help me merge this patch into the master branch? This patch may

Quoted 10 lines

be need for qemu-5.2

Quoted 5 lines

This code has been like this since 2018, so this is not a regression in 5.2. At this point in the release cycle (rc3 imminent) I think it's best to just leave it until 6.0.

OK, I see.

I will send a pull request as soon as the 6.0 cycle starts.

Thanks,
Marcel

Quoted 8 lines

Thanks
Alex

author
#6 lore raw
Quoted 16 lines · Marcel Apfelbaum

Hi Alex,

On Wed, Nov 25, 2020 at 3:17 AM Alex Chen <[email protected] <mailto:[email protected]>> wrote:

On 2020/11/24 23:29, Peter Maydell wrote:
> On Tue, 24 Nov 2020 at 12:15, Alex Chen <[email protected] <mailto:[email protected]>> wrote:
>>
>> Hi everyone,
>>
>> Who can help me merge this patch into the master branch? This patch may be need for qemu-5.2 >
> This code has been like this since 2018, so this is not
> a regression in 5.2. At this point in the release cycle
> (rc3 imminent) I think it's best to just leave it until 6.0.
>

Quoted 5 lines

OK, I see.

I will send a pull request as soon as the 6.0 cycle starts.

Thank you.