diff mbox series

[ovs-dev] xcache: Handle null argument for xlate_cache_uninit().

Message ID 1513827761-96181-3-git-send-email-jpettit@ovn.org
State Accepted
Headers show
Series [ovs-dev] xcache: Handle null argument for xlate_cache_uninit(). | expand

Commit Message

Justin Pettit Dec. 21, 2017, 3:42 a.m. UTC
Most other OVS libraries' delete and uninitialization functions allow a
null argument, but this one would cause a segfault.

Signed-off-by: Justin Pettit <jpettit@ovn.org>
---
 ofproto/ofproto-dpif-xlate-cache.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Yifeng Sun Dec. 21, 2017, 6:05 p.m. UTC | #1
Thanks, looks good to me.

Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>


On Wed, Dec 20, 2017 at 7:42 PM, Justin Pettit <jpettit@ovn.org> wrote:

> Most other OVS libraries' delete and uninitialization functions allow a
> null argument, but this one would cause a segfault.
>
> Signed-off-by: Justin Pettit <jpettit@ovn.org>
> ---
>  ofproto/ofproto-dpif-xlate-cache.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/ofproto/ofproto-dpif-xlate-cache.c
> b/ofproto/ofproto-dpif-xlate-cache.c
> index d319d287eadb..24fc769a7a0d 100644
> --- a/ofproto/ofproto-dpif-xlate-cache.c
> +++ b/ofproto/ofproto-dpif-xlate-cache.c
> @@ -279,6 +279,9 @@ xlate_cache_clear(struct xlate_cache *xcache)
>  void
>  xlate_cache_uninit(struct xlate_cache *xcache)
>  {
> +    if (!xcache) {
> +        return;
> +    }
>      xlate_cache_clear(xcache);
>      ofpbuf_uninit(&xcache->entries);
>  }
> --
> 2.7.4
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> https://mail.openvswitch.org/mailman/listinfo/ovs-dev
>
Ben Pfaff Dec. 21, 2017, 6:26 p.m. UTC | #2
On Wed, Dec 20, 2017 at 07:42:41PM -0800, Justin Pettit wrote:
> Most other OVS libraries' delete and uninitialization functions allow a
> null argument, but this one would cause a segfault.
> 
> Signed-off-by: Justin Pettit <jpettit@ovn.org>

Acked-by: Ben Pfaff <blp@ovn.org>
Justin Pettit Dec. 21, 2017, 11:30 p.m. UTC | #3
> On Dec 21, 2017, at 10:05 AM, Yifeng Sun <pkusunyifeng@gmail.com> wrote:
> 
> Thanks, looks good to me.
> 
> Reviewed-by: Yifeng Sun <pkusunyifeng@gmail.com>

Thanks.  I pushed this with yours and Ben's acks.

--Justin
diff mbox series

Patch

diff --git a/ofproto/ofproto-dpif-xlate-cache.c b/ofproto/ofproto-dpif-xlate-cache.c
index d319d287eadb..24fc769a7a0d 100644
--- a/ofproto/ofproto-dpif-xlate-cache.c
+++ b/ofproto/ofproto-dpif-xlate-cache.c
@@ -279,6 +279,9 @@  xlate_cache_clear(struct xlate_cache *xcache)
 void
 xlate_cache_uninit(struct xlate_cache *xcache)
 {
+    if (!xcache) {
+        return;
+    }
     xlate_cache_clear(xcache);
     ofpbuf_uninit(&xcache->entries);
 }