Message ID | 20240523191152.589605-1-mkp@redhat.com |
---|---|
State | Changes Requested |
Headers | show |
Series | [ovs-dev,v2,1/6] netdev-offload: Fix null pointer dereference' warnings on dump creation. | expand |
Context | Check | Description |
---|---|---|
ovsrobot/apply-robot | warning | apply and check: warning |
ovsrobot/github-robot-_Build_and_Test | success | github build: passed |
ovsrobot/intel-ovs-compilation | success | test: success |
Bleep bloop. Greetings Mike Pattrick, I am a robot and I have tried out your patch. Thanks for your contribution. I encountered some error that I wasn't expecting. See the details below. checkpatch: WARNING: The subject, '<area>: <summary>', is over 70 characters, i.e., 72. Subject: netdev-offload: Fix null pointer dereference' warnings on dump creation. Lines checked: 58, Warnings: 1, Errors: 0 Please check this out. If you feel there has been an error, please email aconole@redhat.com Thanks, 0-day Robot
diff --git a/lib/netdev-offload.c b/lib/netdev-offload.c index 931d634e1..8a9d36555 100644 --- a/lib/netdev-offload.c +++ b/lib/netdev-offload.c @@ -626,8 +626,8 @@ netdev_ports_traverse(const char *dpif_type, struct netdev_flow_dump ** netdev_ports_flow_dump_create(const char *dpif_type, int *ports, bool terse) { + struct netdev_flow_dump **dumps = NULL; struct port_to_netdev_data *data; - struct netdev_flow_dump **dumps; int count = 0; int i = 0; @@ -638,7 +638,11 @@ netdev_ports_flow_dump_create(const char *dpif_type, int *ports, bool terse) } } - dumps = count ? xzalloc(sizeof *dumps * count) : NULL; + if (!count) { + goto unlock; + } + + dumps = xzalloc(sizeof *dumps * count); HMAP_FOR_EACH (data, portno_node, &port_to_netdev) { if (netdev_get_dpif_type(data->netdev) == dpif_type) { @@ -650,6 +654,8 @@ netdev_ports_flow_dump_create(const char *dpif_type, int *ports, bool terse) i++; } } + +unlock: ovs_rwlock_unlock(&port_to_netdev_rwlock); *ports = i;
Clang's static analyzer will complain about a null pointer dereference because dumps can be set to null and then there is a loop where it could have been written to. This is a false positive, but only because the netdev dpif type won't change during this loop. Instead, return early from the netdev_ports_flow_dump_create function if dumps is NULL. Signed-off-by: Mike Pattrick <mkp@redhat.com> --- lib/netdev-offload.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)