asoc: codecs: bolero: Add checks before accessing allocated pointer
Add null checks to regmap allocation and kalloc
failure cases.
Change-Id: I81c35672e43db671b4626fb47d706919b6a3e7f6
Signed-off-by: Karthikeyan Mani <kmani@codeaurora.org>
diff --git a/asoc/codecs/bolero/bolero-clk-rsc.c b/asoc/codecs/bolero/bolero-clk-rsc.c
index 03befde..0e6faf0 100644
--- a/asoc/codecs/bolero/bolero-clk-rsc.c
+++ b/asoc/codecs/bolero/bolero-clk-rsc.c
@@ -326,6 +326,10 @@
return;
}
regmap = dev_get_regmap(priv->dev->parent, NULL);
+ if (!regmap) {
+ pr_err("%s: regmap is null\n", __func__);
+ return;
+ }
if (enable) {
if (priv->reg_seq_en_cnt++ == 0) {
for (i = 0; i < (priv->num_fs_reg * 2); i += 2) {
@@ -495,6 +499,10 @@
}
clk_name_array = devm_kzalloc(&pdev->dev, clk_cnt * sizeof(char *),
GFP_KERNEL);
+ if (!clk_name_array) {
+ ret = -ENOMEM;
+ goto err;
+ }
ret = of_property_read_string_array(pdev->dev.of_node, "clock-names",
clk_name_array, clk_cnt);