Skip to contentSkip to conversation

drivers/soc/apple/mailbox.c:292 apple_mbox_get() warn: passing zero to 'ERR_PTR'

DISCUSSION Dan Carpenter 1 participant 1 message Nov 11, 2024

lore
Share & tools
lore
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   906bd684e4b1e517dd424a354744c5b0aebef8af
commit: c84292d9d253706267889cf2614400712f15d689 soc: apple: mailbox: Rename config symbol to APPLE_MAILBOX
config: sparc-randconfig-r072-20241107 (https://download.01.org/0day-ci/archive/20241108/[email protected]/config)
compiler: sparc64-linux-gcc (GCC) 14.2.0

If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags

| Reported-by: kernel test robot <[email protected]>
| Reported-by: Dan Carpenter <[email protected]>
| Closes: https://lore.kernel.org/r/[email protected]/

smatch warnings:
drivers/soc/apple/mailbox.c:292 apple_mbox_get() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +292 drivers/soc/apple/mailbox.c

6e1457fcad3ff6 Hector Martin 2023-03-14  282  struct apple_mbox *apple_mbox_get(struct device *dev, int index)
6e1457fcad3ff6 Hector Martin 2023-03-14  283  {
6e1457fcad3ff6 Hector Martin 2023-03-14  284  	struct of_phandle_args args;
6e1457fcad3ff6 Hector Martin 2023-03-14  285  	struct platform_device *pdev;
6e1457fcad3ff6 Hector Martin 2023-03-14  286  	struct apple_mbox *mbox;
6e1457fcad3ff6 Hector Martin 2023-03-14  287  	int ret;
6e1457fcad3ff6 Hector Martin 2023-03-14  288  
6e1457fcad3ff6 Hector Martin 2023-03-14  289  	ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
6e1457fcad3ff6 Hector Martin 2023-03-14  290  					 index, &args);
6e1457fcad3ff6 Hector Martin 2023-03-14  291  	if (ret || !args.np)

6e1457fcad3ff6 Hector Martin 2023-03-14 @292 return ERR_PTR(ret);

This should be something like: return ERR_PTR(ret ?: -EINVAL);

6e1457fcad3ff6 Hector Martin 2023-03-14  293  
6e1457fcad3ff6 Hector Martin 2023-03-14  294  	pdev = of_find_device_by_node(args.np);
6e1457fcad3ff6 Hector Martin 2023-03-14  295  	of_node_put(args.np);
6e1457fcad3ff6 Hector Martin 2023-03-14  296  
6e1457fcad3ff6 Hector Martin 2023-03-14  297  	if (!pdev)
6e1457fcad3ff6 Hector Martin 2023-03-14  298  		return ERR_PTR(EPROBE_DEFER);
6e1457fcad3ff6 Hector Martin 2023-03-14  299  
6e1457fcad3ff6 Hector Martin 2023-03-14  300  	mbox = platform_get_drvdata(pdev);
6e1457fcad3ff6 Hector Martin 2023-03-14  301  	if (!mbox)
6e1457fcad3ff6 Hector Martin 2023-03-14  302  		return ERR_PTR(EPROBE_DEFER);
6e1457fcad3ff6 Hector Martin 2023-03-14  303  
6e1457fcad3ff6 Hector Martin 2023-03-14  304  	if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
6e1457fcad3ff6 Hector Martin 2023-03-14  305  		return ERR_PTR(ENODEV);
6e1457fcad3ff6 Hector Martin 2023-03-14  306  
6e1457fcad3ff6 Hector Martin 2023-03-14  307  	return mbox;
6e1457fcad3ff6 Hector Martin 2023-03-14  308  }
Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki