All of lore.kernel.org
 help / color / mirror / Atom feed
* drivers/usb/misc/onboard_usb_hub_pdevs.c:122:0-1: ERROR: missing put_device; call of_find_device_by_node on line 94, but without a corresponding object release within this function.
@ 2024-01-25 10:42 kernel test robot
  0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2024-01-25 10:42 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Julia Lawall

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
CC: linux-kernel@vger.kernel.org
TO: Matthias Kaehlcke <mka@chromium.org>
CC: Douglas Anderson <dianders@chromium.org>
CC: Ravi Chandra Sadineni <ravisadineni@chromium.org>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   6098d87eaf31f48153c984e2adadf14762520a87
commit: 8bc063641cebf9d555e41d135db2b5035b521768 usb: misc: Add onboard_usb_hub driver
date:   1 year, 7 months ago
:::::: branch date: 10 hours ago
:::::: commit date: 1 year, 7 months ago
config: arm-randconfig-r062-20240117 (https://download.01.org/0day-ci/archive/20240125/202401251839.dwdDFnhs-lkp@intel.com/config)
compiler: clang version 18.0.0git (https://github.com/llvm/llvm-project 9bde5becb44ea071f5e1fa1f5d4071dc8788b18c)

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 <lkp@intel.com>
| Reported-by: Julia Lawall <julia.lawall@inria.fr>
| Closes: https://lore.kernel.org/r/202401251839.dwdDFnhs-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> drivers/usb/misc/onboard_usb_hub_pdevs.c:122:0-1: ERROR: missing put_device; call of_find_device_by_node on line 94, but without a corresponding object release within this function.

vim +122 drivers/usb/misc/onboard_usb_hub_pdevs.c

8bc063641cebf9 Matthias Kaehlcke 2022-06-30   30  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   31  /**
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   32   * onboard_hub_create_pdevs -- create platform devices for onboard USB hubs
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   33   * @parent_hub	: parent hub to scan for connected onboard hubs
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   34   * @pdev_list	: list of onboard hub platform devices owned by the parent hub
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   35   *
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   36   * Creates a platform device for each supported onboard hub that is connected to
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   37   * the given parent hub. The platform device is in charge of initializing the
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   38   * hub (enable regulators, take the hub out of reset, ...) and can optionally
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   39   * control whether the hub remains powered during system suspend or not.
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   40   *
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   41   * To keep track of the platform devices they are added to a list that is owned
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   42   * by the parent hub.
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   43   *
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   44   * Some background about the logic in this function, which can be a bit hard
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   45   * to follow:
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   46   *
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   47   * Root hubs don't have dedicated device tree nodes, but use the node of their
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   48   * HCD. The primary and secondary HCD are usually represented by a single DT
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   49   * node. That means the root hubs of the primary and secondary HCD share the
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   50   * same device tree node (the HCD node). As a result this function can be called
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   51   * twice with the same DT node for root hubs. We only want to create a single
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   52   * platform device for each physical onboard hub, hence for root hubs the loop
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   53   * is only executed for the root hub of the primary HCD. Since the function
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   54   * scans through all child nodes it still creates pdevs for onboard hubs
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   55   * connected to the root hub of the secondary HCD if needed.
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   56   *
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   57   * Further there must be only one platform device for onboard hubs with a peer
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   58   * hub (the hub is a single physical device). To achieve this two measures are
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   59   * taken: pdevs for onboard hubs with a peer are only created when the function
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   60   * is called on behalf of the parent hub that is connected to the primary HCD
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   61   * (directly or through other hubs). For onboard hubs connected to root hubs
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   62   * the function processes the nodes of both peers. A platform device is only
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   63   * created if the peer hub doesn't have one already.
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   64   */
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   65  void onboard_hub_create_pdevs(struct usb_device *parent_hub, struct list_head *pdev_list)
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   66  {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   67  	int i;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   68  	struct usb_hcd *hcd = bus_to_hcd(parent_hub->bus);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   69  	struct device_node *np, *npc;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   70  	struct platform_device *pdev;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   71  	struct pdev_list_entry *pdle;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   72  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   73  	if (!parent_hub->dev.of_node)
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   74  		return;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   75  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   76  	if (!parent_hub->parent && !usb_hcd_is_primary_hcd(hcd))
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   77  		return;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   78  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   79  	for (i = 1; i <= parent_hub->maxchild; i++) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   80  		np = usb_of_get_device_node(parent_hub, i);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   81  		if (!np)
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   82  			continue;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   83  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   84  		if (!of_is_onboard_usb_hub(np))
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   85  			goto node_put;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   86  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   87  		npc = of_parse_phandle(np, "peer-hub", 0);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   88  		if (npc) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   89  			if (!usb_hcd_is_primary_hcd(hcd)) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   90  				of_node_put(npc);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   91  				goto node_put;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   92  			}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   93  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  @94  			pdev = of_find_device_by_node(npc);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   95  			of_node_put(npc);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   96  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   97  			if (pdev) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   98  				put_device(&pdev->dev);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30   99  				goto node_put;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  100  			}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  101  		}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  102  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  103  		pdev = of_platform_device_create(np, NULL, &parent_hub->dev);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  104  		if (!pdev) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  105  			dev_err(&parent_hub->dev,
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  106  				"failed to create platform device for onboard hub '%pOF'\n", np);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  107  			goto node_put;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  108  		}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  109  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  110  		pdle = kzalloc(sizeof(*pdle), GFP_KERNEL);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  111  		if (!pdle) {
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  112  			of_platform_device_destroy(&pdev->dev, NULL);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  113  			goto node_put;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  114  		}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  115  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  116  		pdle->pdev = pdev;
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  117  		list_add(&pdle->node, pdev_list);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  118  
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  119  node_put:
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  120  		of_node_put(np);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  121  	}
8bc063641cebf9 Matthias Kaehlcke 2022-06-30 @122  }
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  123  EXPORT_SYMBOL_GPL(onboard_hub_create_pdevs);
8bc063641cebf9 Matthias Kaehlcke 2022-06-30  124  

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-25 10:43 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-25 10:42 drivers/usb/misc/onboard_usb_hub_pdevs.c:122:0-1: ERROR: missing put_device; call of_find_device_by_node on line 94, but without a corresponding object release within this function kernel test robot

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.