ASoC: Intel: avs: Fix unbalanced module reference count

strace_open() invokes try_module_get() which on success takes
the module reference.  If any follow up operation causes
strace_open() to fail, the refcount shall be put down.

Fixes: 0a5fb3cc28 ("ASoC: Intel: avs: Keep module refcount up when gathering traces")
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
Link: https://patch.msgid.link/20260902081814.1590883-9-cezary.rojewski@intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
Cezary Rojewski 2026-09-02 10:18:12 +02:00 committed by Mark Brown
parent 363a6969f7
commit d4fa6f94b9
No known key found for this signature in database
GPG Key ID: 24D68B725D5487D0

View File

@ -9,6 +9,7 @@
#include <linux/cleanup.h>
#include <linux/debugfs.h>
#include <linux/kfifo.h>
#include <linux/module.h>
#include <linux/wait.h>
#include <linux/sched/signal.h>
#include <linux/string_helpers.h>
@ -236,15 +237,20 @@ static int strace_open(struct inode *inode, struct file *file)
if (!try_module_get(adev->dev->driver->owner))
return -ENODEV;
if (kfifo_initialized(&adev->trace_fifo))
return -EBUSY;
if (kfifo_initialized(&adev->trace_fifo)) {
ret = -EBUSY;
goto err;
}
ret = kfifo_alloc(&adev->trace_fifo, PAGE_SIZE, GFP_KERNEL);
if (ret < 0)
return ret;
goto err;
file->private_data = adev;
return 0;
err:
module_put(adev->dev->driver->owner);
return ret;
}
static int strace_release(struct inode *inode, struct file *file)