diff options
| author | Steven Rostedt <rostedt@goodmis.org> | 2026-09-02 09:55:01 -0400 |
|---|---|---|
| committer | Steven Rostedt <rostedt@goodmis.org> | 2026-09-02 11:08:21 -0400 |
| commit | 4617721c502b2ddaa4e324e86da4997edf738fa5 (patch) | |
| tree | 350aa83b47da0b574a814795392b20b0bed83cbc /sound/isa/adlib.c | |
| download | linux-stable-4617721c502b2ddaa4e324e86da4997edf738fa5.tar.gz linux-stable-4617721c502b2ddaa4e324e86da4997edf738fa5.zip | |
ftrace: Synchronize the initialization of ftrace_opsgrafted
There's some internal state that ftrace_ops needs to have set, but since
it can be declared outside of the ftrace.c code, it calls
ftrace_ops_init() on the ops in every global function. The issue is that
if two tasks call it on the same ops at the same time it is possible to
have the initialization of one corrupt the initialization of the other
call.
Create a ops_mutex to use to synchronize every initialization of the
ftrace_ops. The mutex is taken within checking the ftrace_ops flag that
states it was initializied but the flag is checked again after the mutex
has been taken. Checking first outside the mutex allows it to shortcut
having to take the mutex. But then the check needs to be done again after
the mute is taken in case of races.
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20260902095501.6b59af20@gandalf.local.home
Fixes: f04f24fb7e48d ("ftrace, kprobes: Fix a deadlock on ftrace_regex_lock")
Reported-by: sashiko-bot@kernel.org
Close: https://lore.kernel.org/all/20260829025528.49A831F000E9@smtp.kernel.org/
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Diffstat (limited to 'sound/isa/adlib.c')
| -rw-r--r-- | sound/isa/adlib.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/sound/isa/adlib.c b/sound/isa/adlib.c new file mode 100644 index 000000000..03fb2bce9 --- /dev/null +++ b/sound/isa/adlib.c @@ -0,0 +1,99 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * AdLib FM card driver. + */ + +#include <linux/kernel.h> +#include <linux/module.h> +#include <linux/isa.h> +#include <sound/core.h> +#include <sound/initval.h> +#include <sound/opl3.h> + +#define CRD_NAME "AdLib FM" +#define DEV_NAME "adlib" + +MODULE_DESCRIPTION(CRD_NAME); +MODULE_AUTHOR("Rene Herman"); +MODULE_LICENSE("GPL"); + +static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; +static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; +static bool enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE; +static long port[SNDRV_CARDS] = SNDRV_DEFAULT_PORT; + +module_param_array(index, int, NULL, 0444); +MODULE_PARM_DESC(index, "Index value for " CRD_NAME " soundcard."); +module_param_array(id, charp, NULL, 0444); +MODULE_PARM_DESC(id, "ID string for " CRD_NAME " soundcard."); +module_param_array(enable, bool, NULL, 0444); +MODULE_PARM_DESC(enable, "Enable " CRD_NAME " soundcard."); +module_param_hw_array(port, long, ioport, NULL, 0444); +MODULE_PARM_DESC(port, "Port # for " CRD_NAME " driver."); + +static int snd_adlib_match(struct device *dev, unsigned int n) +{ + if (!enable[n]) + return 0; + + if (port[n] == SNDRV_AUTO_PORT) { + dev_err(dev, "please specify port\n"); + return 0; + } + return 1; +} + +static int snd_adlib_probe(struct device *dev, unsigned int n) +{ + struct snd_card *card; + struct snd_opl3 *opl3; + int error; + + error = snd_devm_card_new(dev, index[n], id[n], THIS_MODULE, 0, &card); + if (error < 0) { + dev_err(dev, "could not create card\n"); + return error; + } + + card->private_data = devm_request_region(dev, port[n], 4, CRD_NAME); + if (!card->private_data) { + dev_err(dev, "could not grab ports\n"); + return -EBUSY; + } + + strscpy(card->driver, DEV_NAME); + strscpy(card->shortname, CRD_NAME); + sprintf(card->longname, CRD_NAME " at %#lx", port[n]); + + error = snd_opl3_create(card, port[n], port[n] + 2, OPL3_HW_AUTO, 1, &opl3); + if (error < 0) { + dev_err(dev, "could not create OPL\n"); + return error; + } + + error = snd_opl3_hwdep_new(opl3, 0, 0, NULL); + if (error < 0) { + dev_err(dev, "could not create FM\n"); + return error; + } + + error = snd_card_register(card); + if (error < 0) { + dev_err(dev, "could not register card\n"); + return error; + } + + dev_set_drvdata(dev, card); + return 0; +} + +static struct isa_driver snd_adlib_driver = { + .match = snd_adlib_match, + .probe = snd_adlib_probe, + + .driver = { + .name = DEV_NAME + } +}; + +module_isa_driver(snd_adlib_driver, SNDRV_CARDS); |
