Commit 82b21ca1 authored by Andy Shevchenko's avatar Andy Shevchenko Committed by Mark Brown

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: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: default avatarPeter Ujfalusi <peter.ujfalusi@linux.intel.com>
Link: https://lore.kernel.org/r/20221117103223.74425-1-andriy.shevchenko@linux.intel.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 6b6ab406
...@@ -399,23 +399,21 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev, ...@@ -399,23 +399,21 @@ static int sof_probes_client_probe(struct auxiliary_device *auxdev,
if (!sof_probes_enabled) if (!sof_probes_enabled)
return -ENXIO; return -ENXIO;
if (!dev->platform_data) { ops = dev_get_platdata(dev);
if (!ops) {
dev_err(dev, "missing platform data\n"); dev_err(dev, "missing platform data\n");
return -ENODEV; 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 || if (!ops->startup || !ops->shutdown || !ops->set_params || !ops->trigger ||
!ops->pointer) { !ops->pointer) {
dev_err(dev, "missing platform callback(s)\n"); dev_err(dev, "missing platform callback(s)\n");
return -ENODEV; return -ENODEV;
} }
priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->host_ops = ops; priv->host_ops = ops;
switch (sof_client_get_ipc_type(cdev)) { switch (sof_client_get_ipc_type(cdev)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment