misc: k3_avs: Fix possible NULL pointer deference
authorVignesh Raghavendra <vigneshr@ti.com>
Fri, 14 Feb 2020 12:22:17 +0000 (17:52 +0530)
committerLokesh Vutla <lokeshvutla@ti.com>
Wed, 26 Feb 2020 13:05:29 +0000 (18:35 +0530)
Its possible that k3_avs_priv is NULL because the driver may not have
been probed yet. Therefore check if pointer is valid before
dereferencing it.

Signed-off-by: Vignesh Raghavendra <vigneshr@ti.com>
drivers/misc/k3_avs.c

index 47e42738e04764a093e5344c471f5ccafb01be74..90df377250511166cc5c03f3f5c86dd339c4cb88 100644 (file)
@@ -191,6 +191,10 @@ int k3_avs_notify_freq(int dev_id, int clk_id, u32 freq)
        struct k3_avs_privdata *priv = k3_avs_priv;
        struct vd_data *vd;
 
+       /* Driver may not be probed yet */
+       if (!priv)
+               return -EINVAL;
+
        for (vd = priv->vd_config->vds; vd->id >= 0; vd++) {
                if (vd->dev_id != dev_id || vd->clk_id != clk_id)
                        continue;