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, Pawel Laszczak <pawell@cadence.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org,
	linux-kernel@vger.kernel.org, Peter Chen <peter.chen@nxp.com>
Subject: drivers/usb/cdns3/cdnsp-mem.c:1076 cdnsp_mem_cleanup() warn: variable dereferenced before check 'pdev->dcbaa' (see line 1058)
Date: Wed, 28 Apr 2021 12:49:58 +0300	[thread overview]
Message-ID: <20210428094958.GR1981@kadam> (raw)

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

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   5bfc75d92efd494db37f5c4c173d3639d4772966
commit: 3d82904559f4f5a2622db1b21de3edf2eded7664 usb: cdnsp: cdns3 Add main part of Cadence USBSSP DRD Driver
config: ia64-randconfig-m031-20210423 (attached as .config)
compiler: ia64-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/usb/cdns3/cdnsp-mem.c:1076 cdnsp_mem_cleanup() warn: variable dereferenced before check 'pdev->dcbaa' (see line 1058)

vim +1076 drivers/usb/cdns3/cdnsp-mem.c

3d82904559f4f5 Pawel Laszczak 2020-12-07  1054  void cdnsp_mem_cleanup(struct cdnsp_device *pdev)
3d82904559f4f5 Pawel Laszczak 2020-12-07  1055  {
3d82904559f4f5 Pawel Laszczak 2020-12-07  1056  	struct device *dev = pdev->dev;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1057  
3d82904559f4f5 Pawel Laszczak 2020-12-07 @1058  	cdnsp_free_priv_device(pdev);
                                                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Dereferences "pdev->dcbaa" without checking

3d82904559f4f5 Pawel Laszczak 2020-12-07  1059  	cdnsp_free_erst(pdev, &pdev->erst);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1060  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1061  	if (pdev->event_ring)
3d82904559f4f5 Pawel Laszczak 2020-12-07  1062  		cdnsp_ring_free(pdev, pdev->event_ring);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1063  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1064  	pdev->event_ring = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1065  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1066  	if (pdev->cmd_ring)
3d82904559f4f5 Pawel Laszczak 2020-12-07  1067  		cdnsp_ring_free(pdev, pdev->cmd_ring);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1068  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1069  	pdev->cmd_ring = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1070  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1071  	dma_pool_destroy(pdev->segment_pool);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1072  	pdev->segment_pool = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1073  	dma_pool_destroy(pdev->device_pool);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1074  	pdev->device_pool = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1075  
3d82904559f4f5 Pawel Laszczak 2020-12-07 @1076  	if (pdev->dcbaa)
                                                            ^^^^^^^^^^^
Too late

3d82904559f4f5 Pawel Laszczak 2020-12-07  1077  		dma_free_coherent(dev, sizeof(*pdev->dcbaa),
3d82904559f4f5 Pawel Laszczak 2020-12-07  1078  				  pdev->dcbaa, pdev->dcbaa->dma);
3d82904559f4f5 Pawel Laszczak 2020-12-07  1079  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1080  	pdev->dcbaa = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1081  
3d82904559f4f5 Pawel Laszczak 2020-12-07  1082  	pdev->usb2_port.exist = 0;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1083  	pdev->usb3_port.exist = 0;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1084  	pdev->usb2_port.port_num = 0;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1085  	pdev->usb3_port.port_num = 0;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1086  	pdev->active_port = NULL;
3d82904559f4f5 Pawel Laszczak 2020-12-07  1087  }

---
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: 24387 bytes --]

                 reply	other threads:[~2021-04-28  9:50 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=20210428094958.GR1981@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild-all@lists.01.org \
    --cc=kbuild@lists.01.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=pawell@cadence.com \
    --cc=peter.chen@nxp.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