From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org, Divya Koppera <Divya.Koppera@microchip.com>
Cc: lkp@intel.com, kbuild-all@lists.01.org, linux-kernel@vger.kernel.org
Subject: drivers/net/phy/micrel.c:2613 lan8814_ptp_probe_once() warn: passing zero to 'PTR_ERR'
Date: Thu, 14 Jul 2022 13:59:34 +0300 [thread overview]
Message-ID: <202207132330.qoXbH2DO-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: b047602d579b4fb028128a525f056bbdc890e7f0
commit: ece19502834d84ece2e056db28257ca2aa6e4d48 net: phy: micrel: 1588 support for LAN8814 phy
config: openrisc-randconfig-m031-20220712 (https://download.01.org/0day-ci/archive/20220713/202207132330.qoXbH2DO-lkp@intel.com/config)
compiler: or1k-linux-gcc (GCC) 11.3.0
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/net/phy/micrel.c:2613 lan8814_ptp_probe_once() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +2613 drivers/net/phy/micrel.c
ece19502834d84 Divya Koppera 2022-03-04 2589 static int lan8814_ptp_probe_once(struct phy_device *phydev)
ece19502834d84 Divya Koppera 2022-03-04 2590 {
ece19502834d84 Divya Koppera 2022-03-04 2591 struct lan8814_shared_priv *shared = phydev->shared->priv;
ece19502834d84 Divya Koppera 2022-03-04 2592
ece19502834d84 Divya Koppera 2022-03-04 2593 /* Initialise shared lock for clock*/
ece19502834d84 Divya Koppera 2022-03-04 2594 mutex_init(&shared->shared_lock);
ece19502834d84 Divya Koppera 2022-03-04 2595
ece19502834d84 Divya Koppera 2022-03-04 2596 shared->ptp_clock_info.owner = THIS_MODULE;
ece19502834d84 Divya Koppera 2022-03-04 2597 snprintf(shared->ptp_clock_info.name, 30, "%s", phydev->drv->name);
ece19502834d84 Divya Koppera 2022-03-04 2598 shared->ptp_clock_info.max_adj = 31249999;
ece19502834d84 Divya Koppera 2022-03-04 2599 shared->ptp_clock_info.n_alarm = 0;
ece19502834d84 Divya Koppera 2022-03-04 2600 shared->ptp_clock_info.n_ext_ts = 0;
ece19502834d84 Divya Koppera 2022-03-04 2601 shared->ptp_clock_info.n_pins = 0;
ece19502834d84 Divya Koppera 2022-03-04 2602 shared->ptp_clock_info.pps = 0;
ece19502834d84 Divya Koppera 2022-03-04 2603 shared->ptp_clock_info.pin_config = NULL;
ece19502834d84 Divya Koppera 2022-03-04 2604 shared->ptp_clock_info.adjfine = lan8814_ptpci_adjfine;
ece19502834d84 Divya Koppera 2022-03-04 2605 shared->ptp_clock_info.adjtime = lan8814_ptpci_adjtime;
ece19502834d84 Divya Koppera 2022-03-04 2606 shared->ptp_clock_info.gettime64 = lan8814_ptpci_gettime64;
ece19502834d84 Divya Koppera 2022-03-04 2607 shared->ptp_clock_info.settime64 = lan8814_ptpci_settime64;
ece19502834d84 Divya Koppera 2022-03-04 2608 shared->ptp_clock_info.getcrosststamp = NULL;
ece19502834d84 Divya Koppera 2022-03-04 2609
ece19502834d84 Divya Koppera 2022-03-04 2610 shared->ptp_clock = ptp_clock_register(&shared->ptp_clock_info,
ece19502834d84 Divya Koppera 2022-03-04 2611 &phydev->mdio.dev);
ece19502834d84 Divya Koppera 2022-03-04 2612 if (IS_ERR_OR_NULL(shared->ptp_clock)) {
This code isn't right. It should be:
if (IS_ERR((shared->ptp_clock))) {
If ptp_clock_register() returns NULL then it means that it was
deliberately disabled in the .config. Ideally the driver could just
accept a NULL and continue to boot if that's what the user has asked
for. However if that's not a valid option then just add a depend to the
Kconfig file. The Kconfig stuff around CONFIG_PTP_1588_CLOCK is
slightly complicated and you might want to add a CONFIG_COMPILE_TEST
etc.
But what we don't want is what this code does which is allow the driver
to be compiled in such a way that it can never be used.
ece19502834d84 Divya Koppera 2022-03-04 @2613 phydev_err(phydev, "ptp_clock_register failed %lu\n",
ece19502834d84 Divya Koppera 2022-03-04 2614 PTR_ERR(shared->ptp_clock));
ece19502834d84 Divya Koppera 2022-03-04 2615 return -EINVAL;
ece19502834d84 Divya Koppera 2022-03-04 2616 }
ece19502834d84 Divya Koppera 2022-03-04 2617
ece19502834d84 Divya Koppera 2022-03-04 2618 phydev_dbg(phydev, "successfully registered ptp clock\n");
ece19502834d84 Divya Koppera 2022-03-04 2619
ece19502834d84 Divya Koppera 2022-03-04 2620 shared->phydev = phydev;
ece19502834d84 Divya Koppera 2022-03-04 2621
ece19502834d84 Divya Koppera 2022-03-04 2622 /* The EP.4 is shared between all the PHYs in the package and also it
ece19502834d84 Divya Koppera 2022-03-04 2623 * can be accessed by any of the PHYs
ece19502834d84 Divya Koppera 2022-03-04 2624 */
ece19502834d84 Divya Koppera 2022-03-04 2625 lanphy_write_page_reg(phydev, 4, LTC_HARD_RESET, LTC_HARD_RESET_);
ece19502834d84 Divya Koppera 2022-03-04 2626 lanphy_write_page_reg(phydev, 4, PTP_OPERATING_MODE,
ece19502834d84 Divya Koppera 2022-03-04 2627 PTP_OPERATING_MODE_STANDALONE_);
ece19502834d84 Divya Koppera 2022-03-04 2628
ece19502834d84 Divya Koppera 2022-03-04 2629 return 0;
ece19502834d84 Divya Koppera 2022-03-04 2630 }
--
0-DAY CI Kernel Test Service
https://01.org/lkp
next reply other threads:[~2022-07-14 11:00 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-14 10:59 Dan Carpenter [this message]
-- strict thread matches above, loose matches on Subject: below --
2022-11-22 7:15 drivers/net/phy/micrel.c:2613 lan8814_ptp_probe_once() warn: passing zero to 'PTR_ERR' Dan Carpenter
2023-01-07 8:33 Dan Carpenter
2023-01-09 3:37 ` Divya.Koppera
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=202207132330.qoXbH2DO-lkp@intel.com \
--to=dan.carpenter@oracle.com \
--cc=Divya.Koppera@microchip.com \
--cc=kbuild-all@lists.01.org \
--cc=kbuild@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox