asoc: codecs: Add proper null checks and initialize variables
Add proper null checks and initialize variables
in rx-macro, tx-macro, va-macro and wcd937x drivers.
Change-Id: I90899c84d3391305b9a24d4b043adc08b7c0332a
Signed-off-by: Tanya Dixit <tdixit@codeaurora.org>
diff --git a/asoc/codecs/bolero/rx-macro.c b/asoc/codecs/bolero/rx-macro.c
index 006f863..1a618d0 100644
--- a/asoc/codecs/bolero/rx-macro.c
+++ b/asoc/codecs/bolero/rx-macro.c
@@ -770,6 +770,11 @@
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
int ret = 0, mclk_mux = MCLK_MUX0;
+ if (regmap == NULL) {
+ dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+ return -EINVAL;
+ }
+
dev_dbg(rx_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
__func__, mclk_enable, dapm, rx_priv->rx_mclk_users);
@@ -1570,6 +1575,11 @@
u16 reg_add = 0, coeff_idx = 0, idx = 0;
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
+ if (regmap == NULL) {
+ dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+ return;
+ }
+
regmap_write(regmap,
(BOLERO_CDC_RX_SIDETONE_IIR0_IIR_COEF_B1_CTL + 0x80 * iir_idx),
(band_idx * BAND_MAX * sizeof(uint32_t)) & 0x7F);
@@ -2383,6 +2393,11 @@
struct regmap *regmap = dev_get_regmap(rx_priv->dev->parent, NULL);
int ret = 0;
+ if (regmap == NULL) {
+ dev_err(rx_priv->dev, "%s: regmap is NULL\n", __func__);
+ return -EINVAL;
+ }
+
mutex_lock(&rx_priv->swr_clk_lock);
dev_dbg(rx_priv->dev, "%s: swrm clock %s\n",
diff --git a/asoc/codecs/bolero/tx-macro.c b/asoc/codecs/bolero/tx-macro.c
index 4f9736e..76d424b 100644
--- a/asoc/codecs/bolero/tx-macro.c
+++ b/asoc/codecs/bolero/tx-macro.c
@@ -183,6 +183,11 @@
struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
int ret = 0;
+ if (regmap == NULL) {
+ dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
+ return -EINVAL;
+ }
+
dev_dbg(tx_priv->dev, "%s: mclk_enable = %u,clk_users= %d\n",
__func__, mclk_enable, tx_priv->tx_mclk_users);
@@ -1319,6 +1324,11 @@
struct regmap *regmap = dev_get_regmap(tx_priv->dev->parent, NULL);
int ret = 0;
+ if (regmap == NULL) {
+ dev_err(tx_priv->dev, "%s: regmap is NULL\n", __func__);
+ return -EINVAL;
+ }
+
mutex_lock(&tx_priv->swr_clk_lock);
dev_dbg(tx_priv->dev, "%s: swrm clock %s\n",
diff --git a/asoc/codecs/bolero/va-macro.c b/asoc/codecs/bolero/va-macro.c
index 03bdfa1..eb069fa 100644
--- a/asoc/codecs/bolero/va-macro.c
+++ b/asoc/codecs/bolero/va-macro.c
@@ -143,6 +143,11 @@
struct regmap *regmap = dev_get_regmap(va_priv->dev->parent, NULL);
int ret = 0;
+ if (regmap == NULL) {
+ dev_err(va_priv->dev, "%s: regmap is NULL\n", __func__);
+ return -EINVAL;
+ }
+
dev_dbg(va_priv->dev, "%s: mclk_enable = %u, dapm = %d clk_users= %d\n",
__func__, mclk_enable, dapm, va_priv->va_mclk_users);