All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: wm_adsp: Check for buffer in trigger stop
@ 2019-04-02 12:49 Charles Keepax
  2019-04-02 12:49 ` [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free Charles Keepax
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Charles Keepax @ 2019-04-02 12:49 UTC (permalink / raw)
  To: broonie, lgirdwood; +Cc: patches, alsa-devel

Trigger stop can be called in situations where trigger start failed
and as such it can't be assumed the buffer is already attached to
the compressed stream or a NULL pointer may be dereferenced.

Fixes: 639e5eb3c7d6 ("ASoC: wm_adsp: Correct handling of compressed streams that restart")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 0aa62b26f61cc..2da4ba2da42a8 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3952,7 +3952,8 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
 		}
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		wm_adsp_buffer_clear(compr->buf);
+		if (wm_adsp_compr_attached(compr))
+			wm_adsp_buffer_clear(compr->buf);
 		break;
 	default:
 		ret = -EINVAL;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free
  2019-04-02 12:49 [PATCH 1/3] ASoC: wm_adsp: Check for buffer in trigger stop Charles Keepax
@ 2019-04-02 12:49 ` Charles Keepax
  2019-04-03  4:41   ` Applied "ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free" to the asoc tree Mark Brown
  2019-04-02 12:49 ` [PATCH 3/3] ASoC: wm_adsp: Make use of local variables Charles Keepax
  2019-04-03  4:41 ` Applied "ASoC: wm_adsp: Check for buffer in trigger stop" " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2019-04-02 12:49 UTC (permalink / raw)
  To: broonie, lgirdwood; +Cc: patches, alsa-devel

wm_adsp_compr_detach is NULL aware so there is no need to check for NULL
before calling it, remove the redundant check.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 2da4ba2da42a8..4223186594b4d 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3887,8 +3887,7 @@ static int wm_adsp_buffer_free(struct wm_adsp *dsp)
 	struct wm_adsp_compr_buf *buf, *tmp;
 
 	list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) {
-		if (buf->compr)
-			wm_adsp_compr_detach(buf->compr);
+		wm_adsp_compr_detach(buf->compr);
 
 		kfree(buf->name);
 		kfree(buf->regions);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] ASoC: wm_adsp: Make use of local variables
  2019-04-02 12:49 [PATCH 1/3] ASoC: wm_adsp: Check for buffer in trigger stop Charles Keepax
  2019-04-02 12:49 ` [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free Charles Keepax
@ 2019-04-02 12:49 ` Charles Keepax
  2019-04-03  4:41   ` Applied "ASoC: wm_adsp: Make use of local variables" to the asoc tree Mark Brown
  2019-04-03  4:41 ` Applied "ASoC: wm_adsp: Check for buffer in trigger stop" " Mark Brown
  2 siblings, 1 reply; 6+ messages in thread
From: Charles Keepax @ 2019-04-02 12:49 UTC (permalink / raw)
  To: broonie, lgirdwood; +Cc: patches, alsa-devel

Tidy up some instances of dereferencing to obtain things that are
already stored in local variables.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/wm_adsp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 4223186594b4d..c8c49d5b8ac95 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3381,7 +3381,7 @@ static int wm_adsp_compr_attach(struct wm_adsp_compr *compr)
 		return -EINVAL;
 
 	compr->buf = buf;
-	compr->buf->compr = compr;
+	buf->compr = compr;
 
 	return 0;
 }
@@ -4092,7 +4092,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 
 	buf = compr->buf;
 
-	if (!compr->buf || compr->buf->error) {
+	if (!buf || buf->error) {
 		snd_compr_stop_error(stream, SNDRV_PCM_STATE_XRUN);
 		ret = -EIO;
 		goto out;
@@ -4112,7 +4112,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 		if (buf->avail < wm_adsp_compr_frag_words(compr)) {
 			ret = wm_adsp_buffer_get_error(buf);
 			if (ret < 0) {
-				if (compr->buf->error)
+				if (buf->error)
 					snd_compr_stop_error(stream,
 							SNDRV_PCM_STATE_XRUN);
 				goto out;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Applied "ASoC: wm_adsp: Make use of local variables" to the asoc tree
  2019-04-02 12:49 ` [PATCH 3/3] ASoC: wm_adsp: Make use of local variables Charles Keepax
@ 2019-04-03  4:41   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2019-04-03  4:41 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, broonie, lgirdwood

The patch

   ASoC: wm_adsp: Make use of local variables

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 789b930a8f0de609fd2ef9f2ebf73726b7087fea Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.cirrus.com>
Date: Tue, 2 Apr 2019 13:49:16 +0100
Subject: [PATCH] ASoC: wm_adsp: Make use of local variables

Tidy up some instances of dereferencing to obtain things that are
already stored in local variables.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/wm_adsp.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 6145260d89bf..4662a20cfb92 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3381,7 +3381,7 @@ static int wm_adsp_compr_attach(struct wm_adsp_compr *compr)
 		return -EINVAL;
 
 	compr->buf = buf;
-	compr->buf->compr = compr;
+	buf->compr = compr;
 
 	return 0;
 }
@@ -4091,7 +4091,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 
 	buf = compr->buf;
 
-	if (!compr->buf || compr->buf->error) {
+	if (!buf || buf->error) {
 		snd_compr_stop_error(stream, SNDRV_PCM_STATE_XRUN);
 		ret = -EIO;
 		goto out;
@@ -4111,7 +4111,7 @@ int wm_adsp_compr_pointer(struct snd_compr_stream *stream,
 		if (buf->avail < wm_adsp_compr_frag_words(compr)) {
 			ret = wm_adsp_buffer_get_error(buf);
 			if (ret < 0) {
-				if (compr->buf->error)
+				if (buf->error)
 					snd_compr_stop_error(stream,
 							SNDRV_PCM_STATE_XRUN);
 				goto out;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Applied "ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free" to the asoc tree
  2019-04-02 12:49 ` [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free Charles Keepax
@ 2019-04-03  4:41   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2019-04-03  4:41 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, broonie, lgirdwood

The patch

   ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 26ffa016a3c1b34fbfcc8368edb315f2829504ae Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.cirrus.com>
Date: Tue, 2 Apr 2019 13:49:15 +0100
Subject: [PATCH] ASoC: wm_adsp: Remove redundant NULL check in
 wm_adsp_buffer_free

wm_adsp_compr_detach is NULL aware so there is no need to check for NULL
before calling it, remove the redundant check.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/wm_adsp.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 0aa62b26f61c..6145260d89bf 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3887,8 +3887,7 @@ static int wm_adsp_buffer_free(struct wm_adsp *dsp)
 	struct wm_adsp_compr_buf *buf, *tmp;
 
 	list_for_each_entry_safe(buf, tmp, &dsp->buffer_list, list) {
-		if (buf->compr)
-			wm_adsp_compr_detach(buf->compr);
+		wm_adsp_compr_detach(buf->compr);
 
 		kfree(buf->name);
 		kfree(buf->regions);
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Applied "ASoC: wm_adsp: Check for buffer in trigger stop" to the asoc tree
  2019-04-02 12:49 [PATCH 1/3] ASoC: wm_adsp: Check for buffer in trigger stop Charles Keepax
  2019-04-02 12:49 ` [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free Charles Keepax
  2019-04-02 12:49 ` [PATCH 3/3] ASoC: wm_adsp: Make use of local variables Charles Keepax
@ 2019-04-03  4:41 ` Mark Brown
  2 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2019-04-03  4:41 UTC (permalink / raw)
  To: Charles Keepax; +Cc: patches, alsa-devel, broonie, lgirdwood

The patch

   ASoC: wm_adsp: Check for buffer in trigger stop

has been applied to the asoc tree at

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git 

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.  

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark

>From 43d147be5738a9ed6cfb25c285ac50d6dd5793be Mon Sep 17 00:00:00 2001
From: Charles Keepax <ckeepax@opensource.cirrus.com>
Date: Tue, 2 Apr 2019 13:49:14 +0100
Subject: [PATCH] ASoC: wm_adsp: Check for buffer in trigger stop

Trigger stop can be called in situations where trigger start failed
and as such it can't be assumed the buffer is already attached to
the compressed stream or a NULL pointer may be dereferenced.

Fixes: 639e5eb3c7d6 ("ASoC: wm_adsp: Correct handling of compressed streams that restart")
Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/wm_adsp.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c
index 5608ed5decca..b0b48eb9c7c9 100644
--- a/sound/soc/codecs/wm_adsp.c
+++ b/sound/soc/codecs/wm_adsp.c
@@ -3587,7 +3587,8 @@ int wm_adsp_compr_trigger(struct snd_compr_stream *stream, int cmd)
 		}
 		break;
 	case SNDRV_PCM_TRIGGER_STOP:
-		wm_adsp_buffer_clear(compr->buf);
+		if (wm_adsp_compr_attached(compr))
+			wm_adsp_buffer_clear(compr->buf);
 		break;
 	default:
 		ret = -EINVAL;
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-03  4:41 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02 12:49 [PATCH 1/3] ASoC: wm_adsp: Check for buffer in trigger stop Charles Keepax
2019-04-02 12:49 ` [PATCH 2/3] ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free Charles Keepax
2019-04-03  4:41   ` Applied "ASoC: wm_adsp: Remove redundant NULL check in wm_adsp_buffer_free" to the asoc tree Mark Brown
2019-04-02 12:49 ` [PATCH 3/3] ASoC: wm_adsp: Make use of local variables Charles Keepax
2019-04-03  4:41   ` Applied "ASoC: wm_adsp: Make use of local variables" to the asoc tree Mark Brown
2019-04-03  4:41 ` Applied "ASoC: wm_adsp: Check for buffer in trigger stop" " Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.