@@ -537,9 +537,17 @@ static struct attribute *sugov_attrs[] = {
537
537
};
538
538
ATTRIBUTE_GROUPS (sugov );
539
539
540
+ static void sugov_tunables_free (struct kobject * kobj )
541
+ {
542
+ struct gov_attr_set * attr_set = container_of (kobj , struct gov_attr_set , kobj );
543
+
544
+ kfree (to_sugov_tunables (attr_set ));
545
+ }
546
+
540
547
static struct kobj_type sugov_tunables_ktype = {
541
548
.default_groups = sugov_groups ,
542
549
.sysfs_ops = & governor_sysfs_ops ,
550
+ .release = & sugov_tunables_free ,
543
551
};
544
552
545
553
/********************** cpufreq governor interface *********************/
@@ -639,12 +647,10 @@ static struct sugov_tunables *sugov_tunables_alloc(struct sugov_policy *sg_polic
639
647
return tunables ;
640
648
}
641
649
642
- static void sugov_tunables_free ( struct sugov_tunables * tunables )
650
+ static void sugov_clear_global_tunables ( void )
643
651
{
644
652
if (!have_governor_per_policy ())
645
653
global_tunables = NULL ;
646
-
647
- kfree (tunables );
648
654
}
649
655
650
656
static int sugov_init (struct cpufreq_policy * policy )
@@ -707,7 +713,7 @@ static int sugov_init(struct cpufreq_policy *policy)
707
713
fail :
708
714
kobject_put (& tunables -> attr_set .kobj );
709
715
policy -> governor_data = NULL ;
710
- sugov_tunables_free ( tunables );
716
+ sugov_clear_global_tunables ( );
711
717
712
718
stop_kthread :
713
719
sugov_kthread_stop (sg_policy );
@@ -734,7 +740,7 @@ static void sugov_exit(struct cpufreq_policy *policy)
734
740
count = gov_attr_set_put (& tunables -> attr_set , & sg_policy -> tunables_hook );
735
741
policy -> governor_data = NULL ;
736
742
if (!count )
737
- sugov_tunables_free ( tunables );
743
+ sugov_clear_global_tunables ( );
738
744
739
745
mutex_unlock (& global_tunables_lock );
740
746
0 commit comments