diff mbox series

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

Message ID 5F9AC6FF.4000301@huawei.com
State Accepted
Commit eed31bc5e2e9cc68626d51e7a10914dc52c370f8
Headers show
Series contrib/rdmacm-mux: Fix error condition in hash_tbl_search_fd_by_ifid() | expand

Commit Message

Alex Chen Oct. 29, 2020, 1:43 p.m. UTC
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 <euler.robot@huawei.com>
Signed-off-by: AlexChen <alex.chen@huawei.com>
---
 contrib/rdmacm-mux/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Marcel Apfelbaum Nov. 3, 2020, 4:35 p.m. UTC | #1
Hi Alex,

On Thu, Oct 29, 2020 at 3:43 PM AlexChen <alex.chen@huawei.com> 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 <euler.robot@huawei.com>

> Signed-off-by: AlexChen <alex.chen@huawei.com>

> ---

>  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 <marcel.apfelbaum@gmail.com>


Thanks for the fix,
Marcel
<div dir="ltr"><div dir="ltr">Hi Alex,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Oct 29, 2020 at 3:43 PM AlexChen &lt;<a href="mailto:alex.chen@huawei.com">alex.chen@huawei.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">When fd is not found according to ifid, the _hash_tbl_search_fd_by_ifid()<br>
returns 0 and assigns the result to *fd, so We have to check that *fd is 0,<br>
not that fd is 0.<br>
<br>
Reported-by: Euler Robot &lt;<a href="mailto:euler.robot@huawei.com" target="_blank">euler.robot@huawei.com</a>&gt;<br>
Signed-off-by: AlexChen &lt;<a href="mailto:alex.chen@huawei.com" target="_blank">alex.chen@huawei.com</a>&gt;<br>

---<br>
 contrib/rdmacm-mux/main.c | 2 +-<br>
 1 file changed, 1 insertion(+), 1 deletion(-)<br>
<br>
diff --git a/contrib/rdmacm-mux/main.c b/contrib/rdmacm-mux/main.c<br>
index bd82abbad3..771ca01e03 100644<br>
--- a/contrib/rdmacm-mux/main.c<br>
+++ b/contrib/rdmacm-mux/main.c<br>
@@ -186,7 +186,7 @@ static int hash_tbl_search_fd_by_ifid(int *fd, __be64 *gid_ifid)<br>
     *fd = _hash_tbl_search_fd_by_ifid(gid_ifid);<br>
     pthread_rwlock_unlock(&amp;server.lock);<br>
<br>
-    if (!fd) {<br>
+    if (!*fd) {<br>
         syslog(LOG_WARNING, &quot;Can&#39;t find matching for ifid 0x%llx\n&quot;, *gid_ifid);<br>
         return -ENOENT;<br>
     }<br>
-- <br>
2.19.1<br>
<br></blockquote><div><br></div><div><div>Reviewed-by: Marcel Apfelbaum &lt;<a href="mailto:marcel.apfelbaum@gmail.com">marcel.apfelbaum@gmail.com</a>&gt;</div></div><div><br></div><div>Thanks for the fix,</div><div>Marcel</div><div><br></div><div> </div></div></div>
Alex Chen Nov. 24, 2020, 12:13 p.m. UTC | #2
Hi everyone,

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

Thanks,
Alex

On 2020/11/4 0:35, Marcel Apfelbaum wrote:
> Hi Alex,

> 

> On Thu, Oct 29, 2020 at 3:43 PM AlexChen <alex.chen@huawei.com <mailto:alex.chen@huawei.com>> 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 <euler.robot@huawei.com <mailto:euler.robot@huawei.com>>

>     Signed-off-by: AlexChen <alex.chen@huawei.com <mailto:alex.chen@huawei.com>>

>     ---

>      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 <marcel.apfelbaum@gmail.com <mailto:marcel.apfelbaum@gmail.com>>

> 

> Thanks for the fix,

> Marcel

> 

>
Peter Maydell Nov. 24, 2020, 3:29 p.m. UTC | #3
On Tue, 24 Nov 2020 at 12:15, Alex Chen <alex.chen@huawei.com> 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.

thanks
-- PMM
Alex Chen Nov. 25, 2020, 1:17 a.m. UTC | #4
On 2020/11/24 23:29, Peter Maydell wrote:
> On Tue, 24 Nov 2020 at 12:15, Alex Chen <alex.chen@huawei.com> 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.

> 


OK, I see.

Thanks
Alex
Marcel Apfelbaum Nov. 29, 2020, 6:35 p.m. UTC | #5
Hi Alex,

On Wed, Nov 25, 2020 at 3:17 AM Alex Chen <alex.chen@huawei.com> wrote:

> On 2020/11/24 23:29, Peter Maydell wrote:

> > On Tue, 24 Nov 2020 at 12:15, Alex Chen <alex.chen@huawei.com> 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.

> >

>

> OK, I see.

>

>

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

Thanks,
Marcel


> Thanks

> Alex

>

>

>

>

>

>
<div dir="ltr"><div dir="ltr">Hi Alex,</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 25, 2020 at 3:17 AM Alex Chen &lt;<a href="mailto:alex.chen@huawei.com">alex.chen@huawei.com</a>&gt; wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On 2020/11/24 23:29, Peter Maydell wrote:<br>
&gt; On Tue, 24 Nov 2020 at 12:15, Alex Chen &lt;<a href="mailto:alex.chen@huawei.com" target="_blank">alex.chen@huawei.com</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi everyone,<br>
&gt;&gt;<br>
&gt;&gt; Who can help me merge this patch into the master branch? This patch may be need for qemu-5.2<br>
&gt; <br>
&gt; This code has been like this since 2018, so this is not<br>
&gt; a regression in 5.2. At this point in the release cycle<br>
&gt; (rc3 imminent) I think it&#39;s best to just leave it until 6.0.<br>
&gt; <br>
<br>
OK, I see.<br>
<br></blockquote><div><br></div><div>I will send  a pull request as soon as the 6.0 cycle starts.</div><div><br></div><div>Thanks,</div><div>Marcel</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Thanks<br>
Alex<br>
<br>
<br>
<br>
<br>
<br>
</blockquote></div></div>
Alex Chen Nov. 30, 2020, 9:49 a.m. UTC | #6
On 2020/11/30 2:35, Marcel Apfelbaum wrote:
> Hi Alex,

> 

> On Wed, Nov 25, 2020 at 3:17 AM Alex Chen <alex.chen@huawei.com <mailto:alex.chen@huawei.com>> wrote:

> 

>     On 2020/11/24 23:29, Peter Maydell wrote:

>     > On Tue, 24 Nov 2020 at 12:15, Alex Chen <alex.chen@huawei.com <mailto:alex.chen@huawei.com>> 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.

>     >

> 

>     OK, I see.

> 

> 

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

> 


Thank you.
diff mbox series

Patch

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;
     }