linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation
@ 2022-11-17 10:32 Andy Shevchenko
  2022-11-17 13:37 ` Péter Ujfalusi
  2022-11-18 13:16 ` Mark Brown
  0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2022-11-17 10:32 UTC (permalink / raw)
  To: Mark Brown, Peter Ujfalusi, Pierre-Louis Bossart,
	Ranjani Sridharan, Jyri Sarha, sound-open-firmware, alsa-devel,
	linux-kernel
  Cc: Liam Girdwood, Bard Liao, Kai Vehmanen, Daniel Baluta,
	Jaroslav Kysela, Takashi Iwai, Andy Shevchenko

We may check ops before spending resources on memory allocation.
While at it, utilize dev_get_platdata() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 sound/soc/sof/sof-client-probes.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c
index d08395182b1a..fff126808bc0 100644
--- a/sound/soc/sof/sof-client-probes.c
+++ b/sound/soc/sof/sof-client-probes.c
@@ -399,23 +399,21 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
 	if (!sof_probes_enabled)
 		return -ENXIO;
 
-	if (!dev->platform_data) {
+	ops = dev_get_platdata(dev);
+	if (!ops) {
 		dev_err(dev, "missing platform data\n");
 		return -ENODEV;
 	}
-
-	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
-	if (!priv)
-		return -ENOMEM;
-
-	ops = dev->platform_data;
-
 	if (!ops->startup || !ops->shutdown || !ops->set_params || !ops->trigger ||
 	    !ops->pointer) {
 		dev_err(dev, "missing platform callback(s)\n");
 		return -ENODEV;
 	}
 
+	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+
 	priv->host_ops = ops;
 
 	switch (sof_client_get_ipc_type(cdev)) {
-- 
2.35.1


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

* Re: [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation
  2022-11-17 10:32 [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation Andy Shevchenko
@ 2022-11-17 13:37 ` Péter Ujfalusi
  2022-11-18 13:16 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Péter Ujfalusi @ 2022-11-17 13:37 UTC (permalink / raw)
  To: Andy Shevchenko, Mark Brown, Pierre-Louis Bossart,
	Ranjani Sridharan, Jyri Sarha, sound-open-firmware, alsa-devel,
	linux-kernel
  Cc: Liam Girdwood, Bard Liao, Kai Vehmanen, Daniel Baluta,
	Jaroslav Kysela, Takashi Iwai



On 17/11/2022 12:32, Andy Shevchenko wrote:
> We may check ops before spending resources on memory allocation.

we might.

Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>

> While at it, utilize dev_get_platdata() helper.
> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  sound/soc/sof/sof-client-probes.c | 14 ++++++--------
>  1 file changed, 6 insertions(+), 8 deletions(-)
> 
> diff --git a/sound/soc/sof/sof-client-probes.c b/sound/soc/sof/sof-client-probes.c
> index d08395182b1a..fff126808bc0 100644
> --- a/sound/soc/sof/sof-client-probes.c
> +++ b/sound/soc/sof/sof-client-probes.c
> @@ -399,23 +399,21 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
>  	if (!sof_probes_enabled)
>  		return -ENXIO;
>  
> -	if (!dev->platform_data) {
> +	ops = dev_get_platdata(dev);
> +	if (!ops) {
>  		dev_err(dev, "missing platform data\n");
>  		return -ENODEV;
>  	}
> -
> -	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> -	if (!priv)
> -		return -ENOMEM;
> -
> -	ops = dev->platform_data;
> -
>  	if (!ops->startup || !ops->shutdown || !ops->set_params || !ops->trigger ||
>  	    !ops->pointer) {
>  		dev_err(dev, "missing platform callback(s)\n");
>  		return -ENODEV;
>  	}
>  
> +	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> +	if (!priv)
> +		return -ENOMEM;
> +
>  	priv->host_ops = ops;
>  
>  	switch (sof_client_get_ipc_type(cdev)) {

-- 
Péter

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

* Re: [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation
  2022-11-17 10:32 [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation Andy Shevchenko
  2022-11-17 13:37 ` Péter Ujfalusi
@ 2022-11-18 13:16 ` Mark Brown
  1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-11-18 13:16 UTC (permalink / raw)
  To: Jyri Sarha, Pierre-Louis Bossart, alsa-devel, Andy Shevchenko,
	Ranjani Sridharan, sound-open-firmware, linux-kernel,
	Peter Ujfalusi
  Cc: Liam Girdwood, Kai Vehmanen, Bard Liao, Takashi Iwai,
	Daniel Baluta, Jaroslav Kysela

On Thu, 17 Nov 2022 12:32:23 +0200, Andy Shevchenko wrote:
> We may check ops before spending resources on memory allocation.
> While at it, utilize dev_get_platdata() helper.
> 
> 

Applied to

   broonie/sound.git for-next

Thanks!

[1/1] ASoC: SOF: probes: Check ops before memory allocation
      commit: 82b21ca1912723a53534086864ee0daceb604cb5

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

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

end of thread, other threads:[~2022-11-18 13:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-17 10:32 [PATCH v1 1/1] ASoC: SOF: probes: Check ops before memory allocation Andy Shevchenko
2022-11-17 13:37 ` Péter Ujfalusi
2022-11-18 13:16 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).