[bug report] device property: Add helper to match multiple connections

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Bjorn Andersson,

The patch 7a20917d30fb: "device property: Add helper to match
multiple connections" from Apr 22, 2022 (linux-next), leads to the
following Smatch static checker warning:

	drivers/base/property.c:1374 fwnode_devcon_matches()
	warn: 'ret' is an error pointer or valid

drivers/base/property.c
    1353 static unsigned int fwnode_devcon_matches(const struct fwnode_handle *fwnode,
    1354                                           const char *con_id, void *data,
    1355                                           devcon_match_fn_t match,
    1356                                           void **matches,
    1357                                           unsigned int matches_len)
    1358 {
    1359         struct fwnode_handle *node;
    1360         unsigned int count = 0;
    1361         unsigned int i;
    1362         void *ret;
    1363 
    1364         for (i = 0; ; i++) {
    1365                 if (matches && count >= matches_len)
    1366                         break;
    1367 
    1368                 node = fwnode_find_reference(fwnode, con_id, i);
    1369                 if (IS_ERR(node))
    1370                         break;
    1371 
    1372                 ret = match(node, NULL, data);

This is hard to analyze.  Smatch is doing something wrong but it still
ends up looking basically like Smatch is right?

According to Smatch on my config these are the match() functions
usb_role_switch_match(), typec_retimer_match(), typec_switch_match()
and typec_mux_match().  They can all return ERR_PTR(-EPROBE_DEFER).

    1373                 fwnode_handle_put(node);
--> 1374                 if (ret) {
    1375                         if (matches)
    1376                                 matches[count] = ret;
                                         ^^^^^^^^^^^^^^^^^^^^^
Do we want to record that here or treat it as an error?

    1377                         count++;
    1378                 }
    1379         }
    1380 
    1381         return count;
    1382 }

regards,
dan carpenter




[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]
  Powered by Linux