[bug report] soc: apple: rtkit: Port to the internal mailbox driver

Dan Carpenter dan.carpenter at linaro.org
Mon Mar 31 02:46:01 PDT 2025


Hello Hector Martin,

Commit bb538effdc71 ("soc: apple: rtkit: Port to the internal mailbox
driver") from Mar 14, 2023 (linux-next), leads to the following
Smatch static checker warning:

	drivers/soc/apple/rtkit.c:696 apple_rtkit_init()
	warn: 'rtk->mbox' can also be NULL

drivers/soc/apple/rtkit.c
    686         if (mbox_name)
    687                 rtk->mbox = apple_mbox_get_byname(dev, mbox_name);
    688         else
    689                 rtk->mbox = apple_mbox_get(dev, mbox_idx);
    690 
    691         if (IS_ERR(rtk->mbox)) {
    692                 ret = PTR_ERR(rtk->mbox);
    693                 goto free_rtk;
    694         }
    695 
--> 696         rtk->mbox->rx = apple_rtkit_rx;
    697         rtk->mbox->cookie = rtk;
    698 

The issue is in apple_mbox_get()

drivers/soc/apple/rtkit.c
   283  struct apple_mbox *apple_mbox_get(struct device *dev, int index)
   284  {
   285          struct of_phandle_args args;
   286          struct platform_device *pdev;
   287          struct apple_mbox *mbox;
   288          int ret;
   289  
   290          ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
   291                                           index, &args);
   292          if (ret || !args.np)
                           ^^^^^^^^
Should we return an error pointer if args.np is NULL?

   293                  return ERR_PTR(ret);
   294  
   295          pdev = of_find_device_by_node(args.np);
   296          of_node_put(args.np);
   297  
   298          if (!pdev)
   299                  return ERR_PTR(-EPROBE_DEFER);
   300  
   301          mbox = platform_get_drvdata(pdev);
   302          if (!mbox)
   303                  return ERR_PTR(-EPROBE_DEFER);
   304  
   305          if (!device_link_add(dev, &pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER))
   306                  return ERR_PTR(-ENODEV);
   307  
   308          return mbox;
   309  }

regards,
dan carpenter



More information about the linux-arm-kernel mailing list