summaryrefslogtreecommitdiff
path: root/ofproto/ofproto-dpif-sflow.c
diff options
context:
space:
mode:
authorGavin Li <gavinl@nvidia.com>2021-04-19 10:26:04 +0300
committerSimon Horman <simon.horman@netronome.com>2021-04-21 11:53:50 +0200
commita019868a6268e4a362447c9317b33f056bef2c34 (patch)
tree3fc336a015e00647f90dcdfccdfaac0214097c64 /ofproto/ofproto-dpif-sflow.c
parent5dce24d04de7e1210bf6215955bcc17489010ada (diff)
downloadopenvswitch-a019868a6268e4a362447c9317b33f056bef2c34.tar.gz
ofproto/ofproto-dpif-sflow: Check sflow agent in case of race
sFlow agent may not exist while calling dpif_sflow_received. The sFlow may be deleted in another thread, eg, by user, which will cause crash. Signed-off-by: Gavin Li <gavinl@nvidia.com> Reviewed-by: Gavi Teitz <gavi@nvidia.com> Signed-off-by: Simon Horman <simon.horman@netronome.com>
Diffstat (limited to 'ofproto/ofproto-dpif-sflow.c')
-rw-r--r--ofproto/ofproto-dpif-sflow.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/ofproto/ofproto-dpif-sflow.c b/ofproto/ofproto-dpif-sflow.c
index fdcb9eabb..864c136b5 100644
--- a/ofproto/ofproto-dpif-sflow.c
+++ b/ofproto/ofproto-dpif-sflow.c
@@ -1292,10 +1292,10 @@ dpif_sflow_received(struct dpif_sflow *ds, const struct dp_packet *packet,
ovs_be16 vlan_tci;
ovs_mutex_lock(&mutex);
- sampler = ds->sflow_agent->samplers;
- if (!sampler) {
+ if (!ds->sflow_agent || !ds->sflow_agent->samplers) {
goto out;
}
+ sampler = ds->sflow_agent->samplers;
/* Build a flow sample. */
memset(&fs, 0, sizeof fs);