Skip to content

Commit

Permalink
ofproto: Fix potential NULL pointer dereference in ofproto_type_xx().
Browse files Browse the repository at this point in the history
Ensure a valid class is found before calling it's function pointer.

Signed-off-by: Eelco Chaudron <[email protected]>
Signed-off-by: 0-day Robot <[email protected]>
  • Loading branch information
chaudron authored and ovsrobot committed Feb 5, 2025
1 parent b663309 commit 2c8b28e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ofproto/ofproto.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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);
}
}
Expand Down

0 comments on commit 2c8b28e

Please sign in to comment.