The event_filter_write() function calls event_file_file() to retrieve a trace_event_file associated with a given file struct. If a non-NULL pointer is returned, the function then checks whether the trace_event_file instance has the EVENT_FILE_FL_FREED flag set. This check is redundant because event_file_file() already performs this validation and returns NULL if the flag is set. The err value is also already initialized to -ENODEV. Remove the unnecessary check for EVENT_FILE_FL_FREED in event_filter_write().
Unified · Split
| @@ -2247,12 +2247,8 @@ event_filter_write(struct file *filp, const char __user *ubuf, size_t cnt, · 2246 unmodified lines | |||
| 2247 | 2247 | ||
| 2248 | mutex_lock(&event_mutex); | 2248 | mutex_lock(&event_mutex); |
| 2249 | file = event_file_file(filp); | 2249 | file = event_file_file(filp); |
| 2250 | if (file) { | 2250 | if (file) |
| 2251 | if (file->flags & EVENT_FILE_FL_FREED) | 2251 | err = apply_event_filter(file, buf); |
| 2252 | err = -ENODEV; | ||
| 2253 | else | ||
| 2254 | err = apply_event_filter(file, buf); | ||
| 2255 | } | ||
| 2256 | mutex_unlock(&event_mutex); | 2252 | mutex_unlock(&event_mutex); |
| 2257 | 2253 | ||
| 2258 | kfree(buf); | 2254 | kfree(buf); |