From: Lai Jiangshan Date: Thu, 15 Sep 2011 15:24:03 +0000 (-0400) Subject: avoid leaking crdp for failed path X-Git-Tag: v0.6.5~13 X-Git-Url: http://git.liburcu.org/?p=userspace-rcu.git;a=commitdiff_plain;h=356c8794ee9e562954a52653fbb8f37b7fe16082 avoid leaking crdp for failed path [ Comment: now that set_cpu_call_rcu_data() is not racy and detects overwrites, we can effectively trust its return value and free the crdp if already set. ] Signed-off-by: Lai Jiangshan Signed-off-by: Mathieu Desnoyers --- diff --git a/urcu-call-rcu-impl.h b/urcu-call-rcu-impl.h index ae93468..f9250e8 100644 --- a/urcu-call-rcu-impl.h +++ b/urcu-call-rcu-impl.h @@ -522,8 +522,13 @@ int create_all_cpu_call_rcu_data(unsigned long flags) } call_rcu_unlock(&call_rcu_mutex); if ((ret = set_cpu_call_rcu_data(i, crdp)) != 0) { - /* FIXME: Leaks crdp for now. */ - return ret; /* Can happen on race. */ + call_rcu_data_free(crdp); + + /* it has been created by other thread */ + if (ret == -EEXIST) + continue; + + return ret; } } return 0;