From: kernel test robot <lkp@intel.com>
To: kbuild@lists.01.org
Subject: [char-misc:char-misc-testing 12/47] drivers/misc/open-dice.c:130 open_dice_probe() warn: impossible condition '(rmem->size > (~0)) => (0-u32max > u32max)'
Date: Wed, 09 Feb 2022 20:05:04 +0800 [thread overview]
Message-ID: <202202091905.4SY8mena-lkp@intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 5033 bytes --]
CC: kbuild-all(a)lists.01.org
CC: linux-kernel(a)vger.kernel.org
TO: David Brazdil <dbrazdil@google.com>
CC: "Greg Kroah-Hartman" <gregkh@linuxfoundation.org>
tree: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git char-misc-testing
head: 0580565dd717cb135633ebdbc1d84fe6b0a3fa78
commit: f396ededbd8bf5911d588b683a3ce335844b7c89 [12/47] misc: open-dice: Add driver to expose DICE data to userspace
:::::: branch date: 5 hours ago
:::::: commit date: 5 days ago
config: powerpc-randconfig-m031-20220208 (https://download.01.org/0day-ci/archive/20220209/202202091905.4SY8mena-lkp(a)intel.com/config)
compiler: powerpc-linux-gcc (GCC) 11.2.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/misc/open-dice.c:130 open_dice_probe() warn: impossible condition '(rmem->size > (~0)) => (0-u32max > u32max)'
vim +130 drivers/misc/open-dice.c
f396ededbd8bf5 David Brazdil 2022-01-26 115
f396ededbd8bf5 David Brazdil 2022-01-26 116 static int __init open_dice_probe(struct platform_device *pdev)
f396ededbd8bf5 David Brazdil 2022-01-26 117 {
f396ededbd8bf5 David Brazdil 2022-01-26 118 static unsigned int dev_idx;
f396ededbd8bf5 David Brazdil 2022-01-26 119 struct device *dev = &pdev->dev;
f396ededbd8bf5 David Brazdil 2022-01-26 120 struct reserved_mem *rmem;
f396ededbd8bf5 David Brazdil 2022-01-26 121 struct open_dice_drvdata *drvdata;
f396ededbd8bf5 David Brazdil 2022-01-26 122 int ret;
f396ededbd8bf5 David Brazdil 2022-01-26 123
f396ededbd8bf5 David Brazdil 2022-01-26 124 rmem = of_reserved_mem_lookup(dev->of_node);
f396ededbd8bf5 David Brazdil 2022-01-26 125 if (!rmem) {
f396ededbd8bf5 David Brazdil 2022-01-26 126 dev_err(dev, "failed to lookup reserved memory\n");
f396ededbd8bf5 David Brazdil 2022-01-26 127 return -EINVAL;
f396ededbd8bf5 David Brazdil 2022-01-26 128 }
f396ededbd8bf5 David Brazdil 2022-01-26 129
f396ededbd8bf5 David Brazdil 2022-01-26 @130 if (!rmem->size || (rmem->size > ULONG_MAX)) {
f396ededbd8bf5 David Brazdil 2022-01-26 131 dev_err(dev, "invalid memory region size\n");
f396ededbd8bf5 David Brazdil 2022-01-26 132 return -EINVAL;
f396ededbd8bf5 David Brazdil 2022-01-26 133 }
f396ededbd8bf5 David Brazdil 2022-01-26 134
f396ededbd8bf5 David Brazdil 2022-01-26 135 if (!PAGE_ALIGNED(rmem->base) || !PAGE_ALIGNED(rmem->size)) {
f396ededbd8bf5 David Brazdil 2022-01-26 136 dev_err(dev, "memory region must be page-aligned\n");
f396ededbd8bf5 David Brazdil 2022-01-26 137 return -EINVAL;
f396ededbd8bf5 David Brazdil 2022-01-26 138 }
f396ededbd8bf5 David Brazdil 2022-01-26 139
f396ededbd8bf5 David Brazdil 2022-01-26 140 drvdata = devm_kmalloc(dev, sizeof(*drvdata), GFP_KERNEL);
f396ededbd8bf5 David Brazdil 2022-01-26 141 if (!drvdata)
f396ededbd8bf5 David Brazdil 2022-01-26 142 return -ENOMEM;
f396ededbd8bf5 David Brazdil 2022-01-26 143
f396ededbd8bf5 David Brazdil 2022-01-26 144 *drvdata = (struct open_dice_drvdata){
f396ededbd8bf5 David Brazdil 2022-01-26 145 .lock = __MUTEX_INITIALIZER(drvdata->lock),
f396ededbd8bf5 David Brazdil 2022-01-26 146 .rmem = rmem,
f396ededbd8bf5 David Brazdil 2022-01-26 147 .misc = (struct miscdevice){
f396ededbd8bf5 David Brazdil 2022-01-26 148 .parent = dev,
f396ededbd8bf5 David Brazdil 2022-01-26 149 .name = drvdata->name,
f396ededbd8bf5 David Brazdil 2022-01-26 150 .minor = MISC_DYNAMIC_MINOR,
f396ededbd8bf5 David Brazdil 2022-01-26 151 .fops = &open_dice_fops,
f396ededbd8bf5 David Brazdil 2022-01-26 152 .mode = 0600,
f396ededbd8bf5 David Brazdil 2022-01-26 153 },
f396ededbd8bf5 David Brazdil 2022-01-26 154 };
f396ededbd8bf5 David Brazdil 2022-01-26 155
f396ededbd8bf5 David Brazdil 2022-01-26 156 /* Index overflow check not needed, misc_register() will fail. */
f396ededbd8bf5 David Brazdil 2022-01-26 157 snprintf(drvdata->name, sizeof(drvdata->name), DRIVER_NAME"%u", dev_idx++);
f396ededbd8bf5 David Brazdil 2022-01-26 158
f396ededbd8bf5 David Brazdil 2022-01-26 159 ret = misc_register(&drvdata->misc);
f396ededbd8bf5 David Brazdil 2022-01-26 160 if (ret) {
f396ededbd8bf5 David Brazdil 2022-01-26 161 dev_err(dev, "failed to register misc device '%s': %d\n",
f396ededbd8bf5 David Brazdil 2022-01-26 162 drvdata->name, ret);
f396ededbd8bf5 David Brazdil 2022-01-26 163 return ret;
f396ededbd8bf5 David Brazdil 2022-01-26 164 }
f396ededbd8bf5 David Brazdil 2022-01-26 165
f396ededbd8bf5 David Brazdil 2022-01-26 166 platform_set_drvdata(pdev, drvdata);
f396ededbd8bf5 David Brazdil 2022-01-26 167 return 0;
f396ededbd8bf5 David Brazdil 2022-01-26 168 }
f396ededbd8bf5 David Brazdil 2022-01-26 169
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
reply other threads:[~2022-02-09 12:05 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=202202091905.4SY8mena-lkp@intel.com \
--to=lkp@intel.com \
--cc=kbuild@lists.01.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.