asoc: codecs: Add proper NULL checks and initialize variables
Add null checks and initialize unintialized variables in wsa macro, wcd937x and wcd937x_slave drivers. CRs-Fixed: 2328286 Change-Id: I76b8d262e42d2b06ece3a6ecba28ed26b13d4447 Signed-off-by: Tanya Dixit <tdixit@codeaurora.org>
This commit is contained in:
@@ -756,6 +756,11 @@ static int wsa_macro_mclk_enable(struct wsa_macro_priv *wsa_priv,
|
||||
struct regmap *regmap = dev_get_regmap(wsa_priv->dev->parent, NULL);
|
||||
int ret = 0;
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
dev_dbg(wsa_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
|
||||
__func__, mclk_enable, dapm, wsa_priv->wsa_mclk_users);
|
||||
|
||||
@@ -2431,6 +2436,11 @@ static int wsa_swrm_clock(void *handle, bool enable)
|
||||
struct wsa_macro_priv *wsa_priv = (struct wsa_macro_priv *) handle;
|
||||
struct regmap *regmap = dev_get_regmap(wsa_priv->dev->parent, NULL);
|
||||
|
||||
if (regmap == NULL) {
|
||||
dev_err(wsa_priv->dev, "%s: regmap is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
mutex_lock(&wsa_priv->swr_clk_lock);
|
||||
|
||||
dev_dbg(wsa_priv->dev, "%s: swrm clock %s\n",
|
||||
|
@@ -166,7 +166,7 @@ static int wcd937x_parse_port_mapping(struct device *dev,
|
||||
char *prop, u8 path)
|
||||
{
|
||||
u32 *dt_array, map_size, map_length;
|
||||
u32 port_num, ch_mask, ch_rate, old_port_num = 0;
|
||||
u32 port_num = 0, ch_mask, ch_rate, old_port_num = 0;
|
||||
u32 slave_port_type, master_port_type;
|
||||
u32 i, ch_iter = 0;
|
||||
int ret = 0;
|
||||
@@ -188,7 +188,8 @@ static int wcd937x_parse_port_mapping(struct device *dev,
|
||||
if (!of_find_property(dev->of_node, prop,
|
||||
&map_size)) {
|
||||
dev_err(dev, "missing port mapping prop %s\n", prop);
|
||||
goto err_pdata_fail;
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
}
|
||||
|
||||
map_length = map_size / (NUM_SWRS_DT_PARAMS * sizeof(u32));
|
||||
@@ -197,13 +198,14 @@ static int wcd937x_parse_port_mapping(struct device *dev,
|
||||
|
||||
if (!dt_array) {
|
||||
ret = -ENOMEM;
|
||||
goto err_pdata_fail;
|
||||
goto err;
|
||||
}
|
||||
ret = of_property_read_u32_array(dev->of_node, prop, dt_array,
|
||||
NUM_SWRS_DT_PARAMS * map_length);
|
||||
if (ret) {
|
||||
dev_err(dev, "%s: Failed to read port mapping from prop %s\n",
|
||||
__func__, prop);
|
||||
ret = -EINVAL;
|
||||
goto err_pdata_fail;
|
||||
}
|
||||
|
||||
@@ -230,7 +232,8 @@ static int wcd937x_parse_port_mapping(struct device *dev,
|
||||
|
||||
err_pdata_fail:
|
||||
kfree(dt_array);
|
||||
return -EINVAL;
|
||||
err:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int wcd937x_tx_connect_port(struct snd_soc_codec *codec,
|
||||
|
@@ -31,6 +31,11 @@ static int wcd937x_slave_bind(struct device *dev,
|
||||
uint8_t devnum = 0;
|
||||
struct swr_device *pdev = to_swr_device(dev);
|
||||
|
||||
if (pdev == NULL) {
|
||||
dev_err(dev, "%s: pdev is NULL\n", __func__);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
wcd937x_slave = devm_kzalloc(&pdev->dev,
|
||||
sizeof(struct wcd937x_slave_priv), GFP_KERNEL);
|
||||
if (!wcd937x_slave)
|
||||
@@ -59,6 +64,11 @@ static void wcd937x_slave_unbind(struct device *dev,
|
||||
struct wcd937x_slave_priv *wcd937x_slave = NULL;
|
||||
struct swr_device *pdev = to_swr_device(dev);
|
||||
|
||||
if (pdev == NULL) {
|
||||
dev_err(dev, "%s: pdev is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
wcd937x_slave = swr_get_dev_data(pdev);
|
||||
if (!wcd937x_slave) {
|
||||
dev_err(&pdev->dev, "%s: wcd937x_slave is NULL\n", __func__);
|
||||
|
Reference in New Issue
Block a user