提交 9f7da130 编写于 作者: D Daniel P. Berrange

Fix leak on OOM when creating nwfilter rule instances

The ebiptablesAddRuleInst method would leak an instance
of ebiptablesRuleInstPtr if it hit OOM when adding it
to the list of instances. Remove the pointless helper
method virNWFilterRuleInstAddData and just inline the
call to VIR_APPEND_ELEMENT and free the instance on
failure.
Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
上级 e23ca83a
......@@ -507,7 +507,11 @@ ebiptablesAddRuleInst(virNWFilterRuleInstPtr res,
inst->priority = priority;
inst->ruleType = ruleType;
return virNWFilterRuleInstAddData(res, inst);
if (VIR_APPEND_ELEMENT(res->data, res->ndata, inst) < 0) {
VIR_FREE(inst);
return -1;
}
return 0;
}
......
......@@ -115,28 +115,6 @@ virNWFilterTechDriverForName(const char *name)
}
/**
* virNWFilterRuleInstAddData:
* @res : pointer to virNWFilterRuleInst object collecting the instantiation
* data of a single firewall rule.
* @data : the opaque data that the driver wants to add
*
* Add instantiation data to a firewall rule. An instantiated firewall
* rule may hold multiple data structure representing its instantiation
* data. This may for example be the case if a rule has been defined
* for bidirectional traffic and data needs to be added to the incoming
* and outgoing chains.
*
* Returns 0 in case of success, -1 in case of an error.
*/
int
virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
void *data)
{
return VIR_APPEND_ELEMENT(res->data, res->ndata, data);
}
static void
virNWFilterRuleInstFree(virNWFilterRuleInstPtr inst)
{
......
......@@ -28,9 +28,6 @@
virNWFilterTechDriverPtr virNWFilterTechDriverForName(const char *name);
int virNWFilterRuleInstAddData(virNWFilterRuleInstPtr res,
void *data);
int virNWFilterTechDriversInit(bool privileged);
void virNWFilterTechDriversShutdown(void);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册