public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Grygorii Strashko <grygorii.strashko@ti.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org,
	Santosh Shilimkar <santosh.shilimkar@oracle.com>,
	Peter Ujfalusi <peter.ujfalusi@ti.com>,
	Tero Kristo <t-kristo@ti.com>
Subject: [kbuild] drivers/soc/ti/k3-ringacc.c:562 k3_ringacc_ring_cfg() warn: variable dereferenced before check 'ring' (see line 559)
Date: Fri, 12 Jun 2020 15:13:21 +0300	[thread overview]
Message-ID: <20200612121321.GG4282@kadam> (raw)

[-- Attachment #1: Type: text/plain, Size: 2436 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   b791d1bdf9212d944d749a5c7ff6febdba241771
commit: 3277e8aa2504d97e022ecb9777d784ac1a439d36 soc: ti: k3: add navss ringacc driver
config: arm64-randconfig-m031-20200612 (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

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

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=3277e8aa2504d97e022ecb9777d784ac1a439d36
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git remote update linus
git checkout 3277e8aa2504d97e022ecb9777d784ac1a439d36
vim +/ring +562 drivers/soc/ti/k3-ringacc.c

3277e8aa2504d97 Grygorii Strashko 2020-01-15  557  int k3_ringacc_ring_cfg(struct k3_ring *ring, struct k3_ring_cfg *cfg)
3277e8aa2504d97 Grygorii Strashko 2020-01-15  558  {
3277e8aa2504d97 Grygorii Strashko 2020-01-15 @559  	struct k3_ringacc *ringacc = ring->parent;
                                                                                     ^^^^^^^^^^^^
Dereference.

3277e8aa2504d97 Grygorii Strashko 2020-01-15  560  	int ret = 0;
3277e8aa2504d97 Grygorii Strashko 2020-01-15  561  
3277e8aa2504d97 Grygorii Strashko 2020-01-15 @562  	if (!ring || !cfg)
                                                             ^^^^
Check too late.  Delete it?

3277e8aa2504d97 Grygorii Strashko 2020-01-15  563  		return -EINVAL;
3277e8aa2504d97 Grygorii Strashko 2020-01-15  564  	if (cfg->elm_size > K3_RINGACC_RING_ELSIZE_256 ||
3277e8aa2504d97 Grygorii Strashko 2020-01-15  565  	    cfg->mode >= K3_RINGACC_RING_MODE_INVALID ||
3277e8aa2504d97 Grygorii Strashko 2020-01-15  566  	    cfg->size & ~K3_RINGACC_CFG_RING_SIZE_ELCNT_MASK ||
3277e8aa2504d97 Grygorii Strashko 2020-01-15  567  	    !test_bit(ring->ring_id, ringacc->rings_inuse))
3277e8aa2504d97 Grygorii Strashko 2020-01-15  568  		return -EINVAL;
3277e8aa2504d97 Grygorii Strashko 2020-01-15  569  
3277e8aa2504d97 Grygorii Strashko 2020-01-15  570  	if (cfg->mode == K3_RINGACC_RING_MODE_MESSAGE &&

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 33292 bytes --]

[-- Attachment #3: Type: text/plain, Size: 149 bytes --]

_______________________________________________
kbuild mailing list -- kbuild@lists.01.org
To unsubscribe send an email to kbuild-leave@lists.01.org

                 reply	other threads:[~2020-06-12 13:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200612121321.GG4282@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=grygorii.strashko@ti.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=peter.ujfalusi@ti.com \
    --cc=santosh.shilimkar@oracle.com \
    --cc=t-kristo@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox