aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/sound/soc/sof/sof-client-probes.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2022-11-17 12:32:23 +0200
committerMark Brown <broonie@kernel.org>2022-11-17 13:58:43 +0000
commit82b21ca1912723a53534086864ee0daceb604cb5 (patch)
tree8bcf315a8c5db88873d893b0acf46220c2e6ae16 /sound/soc/sof/sof-client-probes.c
parentASoC: codecs: wsa883x: Simplify with dev_err_probe (diff)
downloadwireguard-linux-82b21ca1912723a53534086864ee0daceb604cb5.tar.xz
wireguard-linux-82b21ca1912723a53534086864ee0daceb604cb5.zip
ASoC: SOF: probes: Check ops before memory allocation
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> Acked-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com> Link: https://lore.kernel.org/r/20221117103223.74425-1-andriy.shevchenko@linux.intel.com Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'sound/soc/sof/sof-client-probes.c')
-rw-r--r--sound/soc/sof/sof-client-probes.c14
1 files 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)) {