Generated by: iterators/itnull.cocci Many iterators have the property that the first argument is always bound to a real list element, never NULL. Semantic patch information: False positives arise for some iterators that do not have this property, or in cases when the loop cursor is reassigned. The latter should only happen when the matched code is on the way to a loop exit (break, goto, or return). --- a/drivers/thermal/cpu_cooling.c +++ b/drivers/thermal/cpu_cooling.c @@ -297,7 +297,7 @@ static int cpufreq_get_max_state(struct mutex_lock(&cooling_cpufreq_lock); list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { - if (cpufreq_device && cpufreq_device->cool_dev == cdev) { + if (cpufreq_device->cool_dev == cdev) { *state = cpufreq_device->tab_size; ret = 0; break; @@ -320,7 +320,7 @@ static int cpufreq_get_cur_state(struct mutex_lock(&cooling_cpufreq_lock); list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { - if (cpufreq_device && cpufreq_device->cool_dev == cdev) { + if (cpufreq_device->cool_dev == cdev) { *state = cpufreq_device->cpufreq_state; ret = 0; break; @@ -343,7 +343,7 @@ static int cpufreq_set_cur_state(struct mutex_lock(&cooling_cpufreq_lock); list_for_each_entry(cpufreq_device, &cooling_cpufreq_list, node) { - if (cpufreq_device && cpufreq_device->cool_dev == cdev) { + if (cpufreq_device->cool_dev == cdev) { ret = 0; break; } @@ -458,7 +458,7 @@ void cpufreq_cooling_unregister(struct t mutex_lock(&cooling_cpufreq_lock); list_for_each_entry(cpufreq_dev, &cooling_cpufreq_list, node) { - if (cpufreq_dev && cpufreq_dev->cool_dev == cdev) + if (cpufreq_dev->cool_dev == cdev) break; cpufreq_dev_count++; }