diff mbox series

[ovs-dev,1/2] ofproto: Fix potential NULL dereference in ofproto_get_datapath_cap().

Message ID 20210525151608.7754.39691.stgit@dceara.remote.csb
State Accepted
Headers show
Series ofproto: Fix potential NULL dereference with invalid datapath types. | expand

Commit Message

Dumitru Ceara May 25, 2021, 3:16 p.m. UTC
Reproducer:
  ovs-vsctl \
    -- add-br br \
    -- set bridge br datapath-type=foo \
    -- --id=@m create Datapath datapath_version=0 'capabilities={}' \
    -- set Open_vSwitch . datapaths:"foo"=@m

Fixes: 27501802d09f ("ofproto-dpif: Expose datapath capability to ovsdb.")
Signed-off-by: Dumitru Ceara <dceara@redhat.com>
---
 ofproto/ofproto.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Paolo Valerio May 28, 2021, 2:34 p.m. UTC | #1
Dumitru Ceara <dceara@redhat.com> writes:

> Reproducer:
>   ovs-vsctl \
>     -- add-br br \
>     -- set bridge br datapath-type=foo \
>     -- --id=@m create Datapath datapath_version=0 'capabilities={}' \
>     -- set Open_vSwitch . datapaths:"foo"=@m
>
> Fixes: 27501802d09f ("ofproto-dpif: Expose datapath capability to ovsdb.")
> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
> ---

LGTM,
Acked-by: Paolo Valerio <pvalerio@redhat.com>
diff mbox series

Patch

diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
index b91517cd25..bf6a262be2 100644
--- a/ofproto/ofproto.c
+++ b/ofproto/ofproto.c
@@ -968,7 +968,7 @@  ofproto_get_datapath_cap(const char *datapath_type, struct smap *dp_cap)
     datapath_type = ofproto_normalize_type(datapath_type);
     const struct ofproto_class *class = ofproto_class_find__(datapath_type);
 
-    if (class->get_datapath_cap) {
+    if (class && class->get_datapath_cap) {
         class->get_datapath_cap(datapath_type, dp_cap);
     }
 }