Skip to content

Commit 2c0dde6

Browse files
committed
ASoC: SOF: sof-client-ipc-test: Protection against removal while in use
Make sure that the core (the device driver for the DSP) can not be removed while the debugfs file for ipc_test is open (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 746edf2 commit 2c0dde6

1 file changed

Lines changed: 37 additions & 1 deletion

File tree

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

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,32 @@ 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+
struct sof_client_dev *cdev;
37+
int ret;
38+
39+
ret = debugfs_file_get(file->f_path.dentry);
40+
if (unlikely(ret))
41+
return ret;
42+
43+
cdev = inode->i_private;
44+
45+
ret = sof_client_core_module_get(cdev);
46+
if (ret) {
47+
debugfs_file_put(file->f_path.dentry);
48+
return ret;
49+
}
50+
51+
ret = simple_open(inode, file);
52+
if (ret) {
53+
debugfs_file_put(file->f_path.dentry);
54+
sof_client_core_module_put(cdev);
55+
}
56+
57+
return ret;
58+
}
59+
3460
/*
3561
* helper function to perform the flood test. Only one of the two params, ipc_duration_ms
3662
* or ipc_count, will be non-zero and will determine the type of test
@@ -250,11 +276,21 @@ static ssize_t sof_ipc_dfsentry_read(struct file *file, char __user *buffer,
250276
return count;
251277
}
252278

279+
static int sof_ipc_dfsentry_release(struct inode *inode, struct file *file)
280+
{
281+
struct sof_client_dev *cdev = inode->i_private;
282+
283+
debugfs_file_put(file->f_path.dentry);
284+
sof_client_core_module_put(cdev);
285+
return 0;
286+
}
287+
253288
static const struct file_operations sof_ipc_dfs_fops = {
254-
.open = simple_open,
289+
.open = sof_ipc_dfsentry_open,
255290
.read = sof_ipc_dfsentry_read,
256291
.llseek = default_llseek,
257292
.write = sof_ipc_dfsentry_write,
293+
.release = sof_ipc_dfsentry_release,
258294

259295
.owner = THIS_MODULE,
260296
};

0 commit comments

Comments
 (0)