[patch 23/38] CKRM e18: Fix edge cases with empty lists and rule deletion

Gerrit Huizenga
2005-06-23T06:42:22Z

[-- Attachment #1: rbce_modcount_incorrect --]
[-- Type: text/plain, Size: 1340 bytes --]

Fix rule re-insertion to be more careful with empty lists.
Fix rule deletion to not delete rules that are still in a list.

Signed-Off-By: Matt Helsley <matthltc@us.ibm.com>
Signed-Off-By: Gerrit Huizenga <gh@us.ibm.com>

Index: linux-2.6.12-ckrm1/kernel/ckrm/rbce/rbce_main.c
===================================================================
--- linux-2.6.12-ckrm1.orig/kernel/ckrm/rbce/rbce_main.c 2005-06-20 15:04:28.000000000 -0700
+++ linux-2.6.12-ckrm1/kernel/ckrm/rbce/rbce_main.c 2005-06-20 15:04:48.000000000 -0700
@@ -162,8 +162,8 @@ static int insert_rule(struct rbce_rule
}
}
}
- if (type == REINSERT)
- list_del(&rule->obj.link);
+ if ((type == REINSERT) && !list_empty(&rule->obj.link))
+ list_del_init(&rule->obj.link);
else {
/* protect the module from removed if a rule exists */
try_module_get(THIS_MODULE);
@@ -340,12 +340,14 @@ static void __release_rule(struct rbce_r
static inline int __delete_rule(struct rbce_rule *rule)
{
/* make sure we are not referenced by other rules */
+ if (list_empty(&rule->obj.link))
+ return 0;
if (GET_REF(rule))
return -EBUSY;
__release_rule(rule);
put_class(rule->target_class);
release_term_index(rule->index);
- list_del(&rule->obj.link);
+ list_del_init(&rule->obj.link);
gl_num_rules--;
gl_rules_version++;
module_put(THIS_MODULE);

--