Skip to content

Commit cba8df9

Browse files
committed
ASoC: SOF: sof-client-ipc-test: Protection against removal while in use
Add additional protection for the debugfs file to make sure that it can not be removed while it is open. Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
1 parent deb5a0c commit cba8df9

1 file changed

Lines changed: 24 additions & 1 deletion

File tree

sound/soc/sof/sof-client-ipc-test.c

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,21 @@ struct sof_ipc_client_data {
3131
char *buf;
3232
};
3333

34+
static int sof_ipc_dfsentry_open(struct inode *inode, struct file *file)
35+
{
36+
int ret;
37+
38+
ret = debugfs_file_get(file->f_path.dentry);
39+
if (unlikely(ret))
40+
return ret;
41+
42+
ret = simple_open(inode, file);
43+
if (ret)
44+
debugfs_file_put(file->f_path.dentry);
45+
46+
return ret;
47+
}
48+
3449
/*
3550
* helper function to perform the flood test. Only one of the two params, ipc_duration_ms
3651
* or ipc_count, will be non-zero and will determine the type of test
@@ -250,11 +265,19 @@ static ssize_t sof_ipc_dfsentry_read(struct file *file, char __user *buffer,
250265
return count;
251266
}
252267

268+
static int sof_ipc_dfsentry_release(struct inode *inode, struct file *file)
269+
{
270+
debugfs_file_put(file->f_path.dentry);
271+
272+
return 0;
273+
}
274+
253275
static const struct file_operations sof_ipc_dfs_fops = {
254-
.open = simple_open,
276+
.open = sof_ipc_dfsentry_open,
255277
.read = sof_ipc_dfsentry_read,
256278
.llseek = default_llseek,
257279
.write = sof_ipc_dfsentry_write,
280+
.release = sof_ipc_dfsentry_release,
258281

259282
.owner = THIS_MODULE,
260283
};

0 commit comments

Comments
 (0)