Commit 80ff73f7 authored by Grygorii Strashko's avatar Grygorii Strashko Committed by Santosh Shilimkar

soc: ti: k3-ringacc: fix: warn: variable dereferenced before check 'ring'

Fix build warning in k3_ringacc_ring_cfg():

smatch warnings:
drivers/soc/ti/k3-ringacc.c:562 k3_ringacc_ring_cfg() warn: variable dereferenced before check 'ring' (see line 559)

  557  int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
  558  {
 @559           struct k3_ringacc *ringacc = ring->parent;
                                             ^^^^^^^^^^^^
Dereference.

  560           int ret = 0;
  561
 @562           if (!ring || !cfg)
                    ^^^^

Check too late.  Delete it?
Reported-by: default avatarkernel test robot <lkp@intel.com>
Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarGrygorii Strashko <grygorii.strashko@ti.com>
Signed-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@oracle.com>
parent 4927b1ab
...@@ -593,11 +593,13 @@ static int k3_ringacc_ring_cfg_sci(struct k3_ring *ring) ...@@ -593,11 +593,13 @@ static int k3_ringacc_ring_cfg_sci(struct k3_ring *ring)
int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg) int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
{ {
struct k3_ringacc *ringacc = ring->parent; struct k3_ringacc *ringacc;
int ret = 0; int ret = 0;
if (!ring || !cfg) if (!ring || !cfg)
return -EINVAL; return -EINVAL;
ringacc = ring->parent;
if (cfg->elm_size > K3_RINGACC_RING_ELSIZE_256 || if (cfg->elm_size > K3_RINGACC_RING_ELSIZE_256 ||
cfg->mode >= K3_RINGACC_RING_MODE_INVALID || cfg->mode >= K3_RINGACC_RING_MODE_INVALID ||
cfg->size & ~K3_RINGACC_CFG_RING_SIZE_ELCNT_MASK || cfg->size & ~K3_RINGACC_CFG_RING_SIZE_ELCNT_MASK ||
......
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