diff --git a/dsp/codecs/audio_aac.c b/dsp/codecs/audio_aac.c index 80cf13e342c7..6f08bbf1bedb 100644 --- a/dsp/codecs/audio_aac.c +++ b/dsp/codecs/audio_aac.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2010-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2010-2021, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -355,20 +355,24 @@ static int audio_open(struct inode *inode, struct file *file) struct q6audio_aio *audio = NULL; int rc = 0; struct msm_audio_aac_config *aac_config = NULL; + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_aac_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_aac_config), GFP_KERNEL); if (audio->codec_cfg == NULL) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } aac_config = audio->codec_cfg; @@ -389,14 +393,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_alac.c b/dsp/codecs/audio_alac.c index 597ea748e377..bf198b5a01bc 100644 --- a/dsp/codecs/audio_alac.c +++ b/dsp/codecs/audio_alac.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. */ #include @@ -259,18 +259,22 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_alac_" + 5]; + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (!audio) + if (!audio) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_alac_config), GFP_KERNEL); if (!audio->codec_cfg) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -286,14 +290,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_amrnb.c b/dsp/codecs/audio_amrnb.c index ea6d02fcfbba..07248907e366 100644 --- a/dsp/codecs/audio_amrnb.c +++ b/dsp/codecs/audio_amrnb.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2017, 2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017, 2019-2021 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -122,15 +122,18 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; - + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_amrnb_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; + } audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN; audio->miscdevice = &audio_amrnb_misc; @@ -143,14 +146,17 @@ static int audio_open(struct inode *inode, struct file *file) if (!audio->ac) { pr_err("Could not allocate memory for audio client\n"); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_amrwb.c b/dsp/codecs/audio_amrwb.c index 688a94d3ec26..c676e68a0cb9 100644 --- a/dsp/codecs/audio_amrwb.c +++ b/dsp/codecs/audio_amrwb.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2017, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017, 2021 The Linux Foundation. All rights reserved. */ #include @@ -115,16 +115,18 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; - + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_amrwb_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN; audio->miscdevice = &audio_amrwb_misc; audio->wakelock_voted = false; @@ -136,15 +138,17 @@ static int audio_open(struct inode *inode, struct file *file) if (!audio->ac) { pr_err("Could not allocate memory for audio client\n"); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } - + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_amrwbplus.c b/dsp/codecs/audio_amrwbplus.c index 534a2e750efb..5aae84b7bf19 100644 --- a/dsp/codecs/audio_amrwbplus.c +++ b/dsp/codecs/audio_amrwbplus.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2010-2017, 2019-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2010-2017, 2019-2021 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -295,16 +295,21 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_amrwbplus_config_v2), GFP_KERNEL); if (audio->codec_cfg == NULL) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN; @@ -319,15 +324,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } - + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_ape.c b/dsp/codecs/audio_ape.c index 250c7e2107b6..7c5c39a31a9d 100644 --- a/dsp/codecs/audio_ape.c +++ b/dsp/codecs/audio_ape.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2015-2020, The Linux Foundation. All rights reserved. +/* Copyright (c) 2015-2021, The Linux Foundation. All rights reserved. */ #include @@ -240,18 +240,22 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_ape_" + 5]; + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (!audio) + if (!audio) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_ape_config), GFP_KERNEL); if (!audio->codec_cfg) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -267,14 +271,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_evrc.c b/dsp/codecs/audio_evrc.c index 48d26525b0c3..a99577cfbc5a 100644 --- a/dsp/codecs/audio_evrc.c +++ b/dsp/codecs/audio_evrc.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2017, 2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017, 2019, 2021 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -76,16 +76,19 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_evrc_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } /* Settings will be re-config at AUDIO_SET_CONFIG, * but at least we need to have initial config */ @@ -100,15 +103,17 @@ static int audio_open(struct inode *inode, struct file *file) if (!audio->ac) { pr_err("Could not allocate memory for audio client\n"); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } - + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_g711alaw.c b/dsp/codecs/audio_g711alaw.c index 0ee7d1f16cb3..3540380772b9 100644 --- a/dsp/codecs/audio_g711alaw.c +++ b/dsp/codecs/audio_g711alaw.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2017, 2019-2021 The Linux Foundation. All rights reserved. */ #include @@ -214,17 +214,22 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_g711_" + 5]; + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (!audio) + if (!audio) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_g711_dec_config), GFP_KERNEL); if (!audio->codec_cfg) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -243,14 +248,17 @@ static int audio_open(struct inode *inode, struct file *file) __func__); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ /*foramt:G711_ALAW*/ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_g711mlaw.c b/dsp/codecs/audio_g711mlaw.c index dcfd4fca12dd..af47fd9824c9 100644 --- a/dsp/codecs/audio_g711mlaw.c +++ b/dsp/codecs/audio_g711mlaw.c @@ -1,5 +1,5 @@ // SPDX-License-Identifier: GPL-2.0-only -/* Copyright (c) 2016-2017, 2019-2020 The Linux Foundation. All rights reserved. +/* Copyright (c) 2016-2017, 2019-2021 The Linux Foundation. All rights reserved. */ #include @@ -212,17 +212,22 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_g711_" + 5]; + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (!audio) + if (!audio) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_g711_dec_config), GFP_KERNEL); if (!audio->codec_cfg) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -241,14 +246,17 @@ static int audio_open(struct inode *inode, struct file *file) __func__); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ /*foramt:G711_ALAW*/ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_mp3.c b/dsp/codecs/audio_mp3.c index 7228cba3a4e8..aa575c82e3d3 100644 --- a/dsp/codecs/audio_mp3.c +++ b/dsp/codecs/audio_mp3.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2017, 2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017, 2019, 2021 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -81,16 +81,19 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_mp3_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->pcm_cfg.buffer_size = PCM_BUFSZ_MIN; audio->miscdevice = &audio_mp3_misc; audio->wakelock_voted = false; @@ -102,15 +105,17 @@ static int audio_open(struct inode *inode, struct file *file) if (!audio->ac) { pr_err("Could not allocate memory for audio client\n"); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } - + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_multi_aac.c b/dsp/codecs/audio_multi_aac.c index 72a2d5b8b51e..3cffa092f25f 100644 --- a/dsp/codecs/audio_multi_aac.c +++ b/dsp/codecs/audio_multi_aac.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2021, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -411,20 +411,24 @@ static int audio_open(struct inode *inode, struct file *file) struct q6audio_aio *audio = NULL; int rc = 0; struct msm_audio_aac_config *aac_config = NULL; + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_multi_aac_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_aac_config), GFP_KERNEL); if (audio->codec_cfg == NULL) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -443,14 +447,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { diff --git a/dsp/codecs/audio_qcelp.c b/dsp/codecs/audio_qcelp.c index 7e88cfd1b45d..33420be297b5 100644 --- a/dsp/codecs/audio_qcelp.c +++ b/dsp/codecs/audio_qcelp.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2011-2017, 2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2011-2017, 2019, 2021 The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -78,15 +78,18 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; - + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_qcelp_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; + } /* Settings will be re-config at AUDIO_SET_CONFIG, * but at least we need to have initial config @@ -107,15 +110,17 @@ static int audio_open(struct inode *inode, struct file *file) if (!audio->ac) { pr_err("Could not allocate memory for audio client\n"); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } - + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_wma.c b/dsp/codecs/audio_wma.c index 00809414b2ee..c462427be326 100644 --- a/dsp/codecs/audio_wma.c +++ b/dsp/codecs/audio_wma.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2009-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -230,20 +230,23 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; - + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_wma_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_wma_config_v2), GFP_KERNEL); if (audio->codec_cfg == NULL) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -259,14 +262,17 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } rc = audio_aio_open(audio, file); if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM, diff --git a/dsp/codecs/audio_wmapro.c b/dsp/codecs/audio_wmapro.c index aa75efb25c11..f2a66be5ef6c 100644 --- a/dsp/codecs/audio_wmapro.c +++ b/dsp/codecs/audio_wmapro.c @@ -3,7 +3,7 @@ * * Copyright (C) 2008 Google, Inc. * Copyright (C) 2008 HTC Corporation - * Copyright (c) 2009-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2009-2021, The Linux Foundation. All rights reserved. * * This software is licensed under the terms of the GNU General Public * License version 2, as published by the Free Software Foundation, and @@ -302,20 +302,23 @@ static int audio_open(struct inode *inode, struct file *file) { struct q6audio_aio *audio = NULL; int rc = 0; - + unsigned long flags = 0; #ifdef CONFIG_DEBUG_FS /* 4 bytes represents decoder number, 1 byte for terminate string */ char name[sizeof "msm_wmapro_" + 5]; #endif + spin_lock_irqsave(&enc_dec_lock, flags); audio = kzalloc(sizeof(struct q6audio_aio), GFP_KERNEL); - if (audio == NULL) + if (audio == NULL) { + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; - + } audio->codec_cfg = kzalloc(sizeof(struct msm_audio_wmapro_config), GFP_KERNEL); if (audio->codec_cfg == NULL) { kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -332,6 +335,7 @@ static int audio_open(struct inode *inode, struct file *file) pr_err("Could not allocate memory for audio client\n"); kfree(audio->codec_cfg); kfree(audio); + spin_unlock_irqrestore(&enc_dec_lock, flags); return -ENOMEM; } @@ -339,8 +343,10 @@ static int audio_open(struct inode *inode, struct file *file) if (rc < 0) { pr_err_ratelimited("%s: audio_aio_open rc=%d\n", __func__, rc); + spin_unlock_irqrestore(&enc_dec_lock, flags); goto fail; } + spin_unlock_irqrestore(&enc_dec_lock, flags); /* open in T/NT mode */ if ((file->f_mode & FMODE_WRITE) && (file->f_mode & FMODE_READ)) { rc = q6asm_open_read_write(audio->ac, FORMAT_LINEAR_PCM,