On 2/5/25 17:03, Eelco Chaudron wrote:
> Ensure a valid class is found before calling it's function pointer.
> 
> Signed-off-by: Eelco Chaudron <echau...@redhat.com>
> ---
>  ofproto/ofproto.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/ofproto/ofproto.c b/ofproto/ofproto.c
> index dbea03c8f..24e8aae30 100644
> --- a/ofproto/ofproto.c
> +++ b/ofproto/ofproto.c
> @@ -1897,7 +1897,7 @@ ofproto_type_run(const char *datapath_type)
>      datapath_type = ofproto_normalize_type(datapath_type);
>      class = ofproto_class_find__(datapath_type);
>  
> -    error = class->type_run ? class->type_run(datapath_type) : 0;
> +    error = (class && class->type_run) ? class->type_run(datapath_type) : 0;
>      if (error && error != EAGAIN) {
>          VLOG_ERR_RL(&rl, "%s: type_run failed (%s)",
>                      datapath_type, ovs_strerror(error));
> @@ -1913,7 +1913,7 @@ ofproto_type_wait(const char *datapath_type)
>      datapath_type = ofproto_normalize_type(datapath_type);
>      class = ofproto_class_find__(datapath_type);
>  
> -    if (class->type_wait) {
> +    if (class && class->type_wait) {
>          class->type_wait(datapath_type);
>      }
>  }

These should be assertions as well.  This function should not be called
for a datapath type that wasn't previously registered.

Best regards, Ilya Maximets.
_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to