[CPUFREQ] check sysfs_create_link return value
authorAhmed S. Darwish <darwish.07@gmail.com>
Fri, 5 Jan 2007 03:44:54 +0000 (05:44 +0200)
committerDave Jones <davej@redhat.com>
Mon, 29 Jan 2007 05:06:27 +0000 (00:06 -0500)
Trivial patch to check sysfs_create_link return values.
Fail gracefully if needed.

Signed-off-by: Ahmed Darwish <darwish.07@gmail.com>
Signed-off-by: Dave Jones <davej@redhat.com>
drivers/cpufreq/cpufreq.c

index d91330432ba2e4a5010f737d19b31257043371d0..a45cc89e387a3ee14ba2afcda2cb09ac5303b1f0 100644 (file)
@@ -722,8 +722,13 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
                        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
                        dprintk("CPU already managed, adding link\n");
                        spin_unlock_irqrestore(&cpufreq_driver_lock, flags);
 
                        dprintk("CPU already managed, adding link\n");
-                       sysfs_create_link(&sys_dev->kobj,
-                                         &managed_policy->kobj, "cpufreq");
+                       ret = sysfs_create_link(&sys_dev->kobj,
+                                               &managed_policy->kobj,
+                                               "cpufreq");
+                       if (ret) {
+                               mutex_unlock(&policy->lock);
+                               goto err_out_driver_exit;
+                       }
 
                        cpufreq_debug_enable_ratelimit();
                        mutex_unlock(&policy->lock);
 
                        cpufreq_debug_enable_ratelimit();
                        mutex_unlock(&policy->lock);
@@ -770,8 +775,12 @@ static int cpufreq_add_dev (struct sys_device * sys_dev)
                dprintk("CPU %u already managed, adding link\n", j);
                cpufreq_cpu_get(cpu);
                cpu_sys_dev = get_cpu_sysdev(j);
                dprintk("CPU %u already managed, adding link\n", j);
                cpufreq_cpu_get(cpu);
                cpu_sys_dev = get_cpu_sysdev(j);
-               sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
-                                 "cpufreq");
+               ret = sysfs_create_link(&cpu_sys_dev->kobj, &policy->kobj,
+                                       "cpufreq");
+               if (ret) {
+                       mutex_unlock(&policy->lock);
+                       goto err_out_unregister;
+               }
        }
 
        policy->governor = NULL; /* to assure that the starting sequence is
        }
 
        policy->governor = NULL; /* to assure that the starting sequence is