mirror of
https://github.com/torvalds/linux.git
synced 2025-04-12 06:49:52 +00:00
Fix ref count of trace_array in error path of histogram file open
Tracing instances have a ref count to keep them around while files within their directories are open. This prevents them from being deleted while they are used. The histogram code had some files that needed to take the ref count and that was added, but the error paths did not decrement the ref counts. This caused the instances from ever being removed if a histogram file failed to open due to some error. -----BEGIN PGP SIGNATURE----- iIoEABYIADIWIQRRSw7ePDh/lE+zeZMp5XQQmuv6qgUCZ9cE8hQccm9zdGVkdEBn b29kbWlzLm9yZwAKCRAp5XQQmuv6qtm8AQDrdfwo63g/K0xpM0Uej9Ex5pBkHEq/ WwCI2hUbPya0wAEAtEcfvgt7P0GuO0PNOYY3uzhAokfBiN04elatbLEetQ4= =i35g -----END PGP SIGNATURE----- Merge tag 'trace-v6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace Pull tracing fix from Steven Rostedt: "Fix ref count of trace_array in error path of histogram file open Tracing instances have a ref count to keep them around while files within their directories are open. This prevents them from being deleted while they are used. The histogram code had some files that needed to take the ref count and that was added, but the error paths did not decrement the ref counts. This caused the instances from ever being removed if a histogram file failed to open due to some error" * tag 'trace-v6.14-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Correct the refcount if the hist/hist_debug file fails to open
This commit is contained in:
commit
ad87a8d0c4
@ -5689,12 +5689,16 @@ static int event_hist_open(struct inode *inode, struct file *file)
|
||||
guard(mutex)(&event_mutex);
|
||||
|
||||
event_file = event_file_data(file);
|
||||
if (!event_file)
|
||||
return -ENODEV;
|
||||
if (!event_file) {
|
||||
ret = -ENODEV;
|
||||
goto err;
|
||||
}
|
||||
|
||||
hist_file = kzalloc(sizeof(*hist_file), GFP_KERNEL);
|
||||
if (!hist_file)
|
||||
return -ENOMEM;
|
||||
if (!hist_file) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
|
||||
hist_file->file = file;
|
||||
hist_file->last_act = get_hist_hit_count(event_file);
|
||||
@ -5702,9 +5706,14 @@ static int event_hist_open(struct inode *inode, struct file *file)
|
||||
/* Clear private_data to avoid warning in single_open() */
|
||||
file->private_data = NULL;
|
||||
ret = single_open(file, hist_show, hist_file);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
kfree(hist_file);
|
||||
goto err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
err:
|
||||
tracing_release_file_tr(inode, file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -5979,7 +5988,10 @@ static int event_hist_debug_open(struct inode *inode, struct file *file)
|
||||
|
||||
/* Clear private_data to avoid warning in single_open() */
|
||||
file->private_data = NULL;
|
||||
return single_open(file, hist_debug_show, file);
|
||||
ret = single_open(file, hist_debug_show, file);
|
||||
if (ret)
|
||||
tracing_release_file_tr(inode, file);
|
||||
return ret;
|
||||
}
|
||||
|
||||
const struct file_operations event_hist_debug_fops = {
|
||||
|
Loading…
x
Reference in New Issue
Block a user