CC: [email protected]
CC: [email protected]
TO: David Brazdil <[email protected]>
CC: "Greg Kroah-Hartman" <[email protected]>

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/[email protected]/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 <[email protected]>
Reported-by: Dan Carpenter <[email protected]>

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/[email protected]
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to