diff mbox

[ovs-dev] patch: Check the right variable for null.

Message ID 20170527055559.14775-1-blp@ovn.org
State Accepted
Headers show

Commit Message

Ben Pfaff May 27, 2017, 5:55 a.m. UTC
This function tried to check 'iface_peer' for null, but it actually
checked its always-nonnull 'peer' argument instead.  This fixes the
problem.

Found by Coverity.

Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763064&defectInstanceId=4305294&mergedDefectId=179852
Signed-off-by: Ben Pfaff <blp@ovn.org>
---
 ovn/controller/patch.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Justin Pettit June 1, 2017, 11:57 p.m. UTC | #1
> On May 26, 2017, at 10:55 PM, Ben Pfaff <blp@ovn.org> wrote:
> 
> This function tried to check 'iface_peer' for null, but it actually
> checked its always-nonnull 'peer' argument instead.  This fixes the
> problem.
> 
> Found by Coverity.
> 
> Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763064&defectInstanceId=4305294&mergedDefectId=179852
> Signed-off-by: Ben Pfaff <blp@ovn.org>

Acked-by: Justin Pettit <jpettit@ovn.org>

--Justin
Ben Pfaff June 2, 2017, 4:17 a.m. UTC | #2
On Thu, Jun 01, 2017 at 04:57:42PM -0700, Justin Pettit wrote:
> 
> > On May 26, 2017, at 10:55 PM, Ben Pfaff <blp@ovn.org> wrote:
> > 
> > This function tried to check 'iface_peer' for null, but it actually
> > checked its always-nonnull 'peer' argument instead.  This fixes the
> > problem.
> > 
> > Found by Coverity.
> > 
> > Reported-at: https://scan3.coverity.com/reports.htm#v16889/p10449/fileInstanceId=14763064&defectInstanceId=4305294&mergedDefectId=179852
> > Signed-off-by: Ben Pfaff <blp@ovn.org>
> 
> Acked-by: Justin Pettit <jpettit@ovn.org>

Thanks, applied to master, branch-2.7, and branch-2.6.
diff mbox

Patch

diff --git a/ovn/controller/patch.c b/ovn/controller/patch.c
index 158413e91f8c..27c6ac385de1 100644
--- a/ovn/controller/patch.c
+++ b/ovn/controller/patch.c
@@ -1,4 +1,4 @@ 
-/* Copyright (c) 2015, 2016 Nicira, Inc.
+/* Copyright (c) 2015, 2016, 2017 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -43,7 +43,7 @@  match_patch_port(const struct ovsrec_port *port, const char *peer)
             continue;
         }
         const char *iface_peer = smap_get(&iface->options, "peer");
-        if (peer && !strcmp(iface_peer, peer)) {
+        if (iface_peer && !strcmp(iface_peer, peer)) {
             return true;
         }
     }