lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202209180216.pPTbUHZl-lkp@intel.com>
Date:   Mon, 19 Sep 2022 11:47:35 +0300
From:   Dan Carpenter <dan.carpenter@...cle.com>
To:     kbuild@...ts.01.org, Hector Martin <marcan@...can.st>
Cc:     lkp@...el.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: [asahilinux:bits/090-spi-hid 18/22]
 drivers/soc/apple/rtkit-helper.c:46 apple_rtkit_helper_shmem_setup() warn:
 variable dereferenced before check 'helper->sram' (see line 35)

tree:   https://github.com/AsahiLinux/linux bits/090-spi-hid
head:   ecf1fb81499a2f1724cb90497ca3c1cec831c9b6
commit: 51f1f2b38adcb95f2e04665ae54fe99ba6bd7844 [18/22] soc: apple: Add RTKit helper driver
config: arm-randconfig-m041-20220918
compiler: arm-linux-gnueabi-gcc (GCC) 12.1.0

If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@...el.com>
Reported-by: Dan Carpenter <dan.carpenter@...cle.com>

smatch warnings:
drivers/soc/apple/rtkit-helper.c:46 apple_rtkit_helper_shmem_setup() warn: variable dereferenced before check 'helper->sram' (see line 35)

vim +46 drivers/soc/apple/rtkit-helper.c

51f1f2b38adcb9 Hector Martin 2022-07-03  28  static int apple_rtkit_helper_shmem_setup(void *cookie, struct apple_rtkit_shmem *bfr)
51f1f2b38adcb9 Hector Martin 2022-07-03  29  {
51f1f2b38adcb9 Hector Martin 2022-07-03  30  	struct apple_rtkit_helper *helper = cookie;
51f1f2b38adcb9 Hector Martin 2022-07-03  31  	struct resource res = {
51f1f2b38adcb9 Hector Martin 2022-07-03  32  		.start = bfr->iova,
51f1f2b38adcb9 Hector Martin 2022-07-03  33  		.end = bfr->iova + bfr->size - 1,
51f1f2b38adcb9 Hector Martin 2022-07-03  34  		.name = "rtkit_map",
51f1f2b38adcb9 Hector Martin 2022-07-03 @35  		.flags = helper->sram->flags,
                                                                 ^^^^^^^^^^^^^
Dereference

51f1f2b38adcb9 Hector Martin 2022-07-03  36  	};
51f1f2b38adcb9 Hector Martin 2022-07-03  37  
51f1f2b38adcb9 Hector Martin 2022-07-03  38  	if (!bfr->iova) {
51f1f2b38adcb9 Hector Martin 2022-07-03  39  		bfr->buffer = dma_alloc_coherent(helper->dev, bfr->size,
51f1f2b38adcb9 Hector Martin 2022-07-03  40  						    &bfr->iova, GFP_KERNEL);
51f1f2b38adcb9 Hector Martin 2022-07-03  41  		if (!bfr->buffer)
51f1f2b38adcb9 Hector Martin 2022-07-03  42  			return -ENOMEM;
51f1f2b38adcb9 Hector Martin 2022-07-03  43  		return 0;
51f1f2b38adcb9 Hector Martin 2022-07-03  44  	}
51f1f2b38adcb9 Hector Martin 2022-07-03  45  
51f1f2b38adcb9 Hector Martin 2022-07-03 @46  	if (!helper->sram) {
                                                     ^^^^^^^^^^^^
Checked too late.

51f1f2b38adcb9 Hector Martin 2022-07-03  47  		dev_err(helper->dev,
51f1f2b38adcb9 Hector Martin 2022-07-03  48  			"RTKit buffer request with no SRAM region: %pR", &res);
51f1f2b38adcb9 Hector Martin 2022-07-03  49  		return -EFAULT;
51f1f2b38adcb9 Hector Martin 2022-07-03  50  	}
51f1f2b38adcb9 Hector Martin 2022-07-03  51  
51f1f2b38adcb9 Hector Martin 2022-07-03  52  	if (res.end < res.start || !resource_contains(helper->sram, &res)) {
51f1f2b38adcb9 Hector Martin 2022-07-03  53  		dev_err(helper->dev,
51f1f2b38adcb9 Hector Martin 2022-07-03  54  			"RTKit buffer request outside SRAM region: %pR", &res);
51f1f2b38adcb9 Hector Martin 2022-07-03  55  		return -EFAULT;
51f1f2b38adcb9 Hector Martin 2022-07-03  56  	}
51f1f2b38adcb9 Hector Martin 2022-07-03  57  
51f1f2b38adcb9 Hector Martin 2022-07-03  58  	bfr->iomem = helper->sram_base + (res.start - helper->sram->start);
51f1f2b38adcb9 Hector Martin 2022-07-03  59  	bfr->is_mapped = true;
51f1f2b38adcb9 Hector Martin 2022-07-03  60  
51f1f2b38adcb9 Hector Martin 2022-07-03  61  	return 0;
51f1f2b38adcb9 Hector Martin 2022-07-03  62  }

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ