From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Hector Martin <marcan@marcan.st>
Cc: lkp@intel.com, kbuild-all@lists.01.org, linux-kernel@vger.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)
Date: Mon, 19 Sep 2022 11:47:35 +0300 [thread overview]
Message-ID: <202209180216.pPTbUHZl-lkp@intel.com> (raw)
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@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.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 }
reply other threads:[~2022-09-19 8:48 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=202209180216.pPTbUHZl-lkp@intel.com \
--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=marcan@marcan.st \
/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
all inboxes | Powered by JetHome®