Skip to contentSkip to conversation

security/apparmor/label.c: Clean code by removing redundant instructions

PATCH In review [email protected] 2 participants 2 messages Mar 3, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 security/apparmor/label.c: Clean code by removing redundant instructions

From: Mateusz Nosek <[email protected]>

Previously 'label->proxy->label' value checking
and conditional reassigning were done twice in the same function. The second one is redundant and can be removed.

---
 security/apparmor/label.c | 6 ------
 1 file changed, 6 deletions(-)
security/apparmor/label.c +0 -6
index ba3987242282..676eebcbfd68 100644
@@ -311,8 +311,6 @@ int aa_vec_unique(struct aa_profile **vec, int n, int flags)
 
 static void label_destroy(struct aa_label *label)
 {
-	struct aa_label *tmp;
-
 	AA_BUG(!label);
 
 	if (!label_isprofile(label)) {
@@ -333,10 +331,6 @@ static void label_destroy(struct aa_label *label)
 
 	aa_free_secid(label->secid);
 
-	tmp = rcu_dereference_protected(label->proxy->label, true);
-	if (tmp == label)
-		rcu_assign_pointer(label->proxy->label, NULL);
-
 	aa_put_proxy(label->proxy);
 	label->proxy = (struct aa_proxy *) PROXY_POISON + 1;
 }
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 7 lines · On 3/3/20 10:30 AM, [email protected] wrote:

From: Mateusz Nosek <[email protected]>

Previously 'label->proxy->label' value checking
and conditional reassigning were done twice in the same function. The second one is redundant and can be removed.

I will pull this into apparmor-next

Quoted 29 lines
---
 security/apparmor/label.c | 6 ------
 1 file changed, 6 deletions(-)
security/apparmor/label.c +0 -6
index ba3987242282..676eebcbfd68 100644
@@ -311,8 +311,6 @@ int aa_vec_unique(struct aa_profile **vec, int n, int flags)
 
 static void label_destroy(struct aa_label *label)
 {
-	struct aa_label *tmp;
-
 	AA_BUG(!label);
 
 	if (!label_isprofile(label)) {
@@ -333,10 +331,6 @@ static void label_destroy(struct aa_label *label)
 
 	aa_free_secid(label->secid);
 
-	tmp = rcu_dereference_protected(label->proxy->label, true);
-	if (tmp == label)
-		rcu_assign_pointer(label->proxy->label, NULL);
-
 	aa_put_proxy(label->proxy);
 	label->proxy = (struct aa_proxy *) PROXY_POISON + 1;
 }