drivers/phy/cadence/phy-cadence-torrent.c:326 cdns_torrent_dp_init() warn: 'cdns_phy->clk' not released on lines: 280.

From: Dan Carpenter
Date: Thu Sep 17 2020 - 05:51:05 EST


tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 5925fa68fe8244651b3f78a88c4af99190a88f0d
commit: e4b496a376f1ad83d708628e31e90c4e1093a867 phy: cadence-torrent: Add 19.2 MHz reference clock support
config: i386-randconfig-m021-20200916 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>

smatch warnings:
drivers/phy/cadence/phy-cadence-torrent.c:326 cdns_torrent_dp_init() warn: 'cdns_phy->clk' not released on lines: 280.

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e4b496a376f1ad83d708628e31e90c4e1093a867
git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
git fetch --no-tags linus master
git checkout e4b496a376f1ad83d708628e31e90c4e1093a867
vim +326 drivers/phy/cadence/phy-cadence-torrent.c

92e9ccc6dc2249 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 253 static int cdns_torrent_dp_init(struct phy *phy)
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 254 {
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 255 unsigned char lane_bits;
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 256 int ret;
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 257
92e9ccc6dc2249 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 258 struct cdns_torrent_phy *cdns_phy = phy_get_drvdata(phy);
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 259
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 260 ret = clk_prepare_enable(cdns_phy->clk);
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 261 if (ret) {
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 262 dev_err(cdns_phy->dev, "Failed to prepare ref clock\n");
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 263 return ret;
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 264 }
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 265
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 266 cdns_phy->ref_clk_rate = clk_get_rate(cdns_phy->clk);
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 267 if (!(cdns_phy->ref_clk_rate)) {
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 268 dev_err(cdns_phy->dev, "Failed to get ref clock rate\n");
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 269 clk_disable_unprepare(cdns_phy->clk);
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 270 return -EINVAL;
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 271 }
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 272
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 273 switch (cdns_phy->ref_clk_rate) {
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 274 case REF_CLK_19_2MHz:
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 275 case REF_CLK_25MHz:
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 276 /* Valid Ref Clock Rate */
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 277 break;
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 278 default:
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 279 dev_err(cdns_phy->dev, "Unsupported Ref Clock Rate\n");
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 280 return -EINVAL;

This error path should probably call clk_disable_unprepare(cdns_phy->clk);
The same for the other error paths below? The check is only complaining
when the return is definitely negative, but it should probably updated
to say that the other non-zero returns are errors as well.

e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 281 }
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 282
f61b3aed20003e drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 283 cdns_torrent_dp_write(cdns_phy, PHY_AUX_CTRL, 0x0003); /* enable AUX */
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 284
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 285 /* PHY PMA registers configuration function */
92e9ccc6dc2249 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 286 cdns_torrent_dp_pma_cfg(cdns_phy);
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 287
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 288 /*
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 289 * Set lines power state to A0
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 290 * Set lines pll clk enable to 0
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 291 */
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 292 cdns_torrent_dp_set_a0_pll(cdns_phy, cdns_phy->num_lanes);
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 293
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 294 /*
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 295 * release phy_l0*_reset_n and pma_tx_elec_idle_ln_* based on
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 296 * used lanes
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 297 */
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 298 lane_bits = (1 << cdns_phy->num_lanes) - 1;
f61b3aed20003e drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 299 cdns_torrent_dp_write(cdns_phy, PHY_RESET,
f61b3aed20003e drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 300 ((0xF & ~lane_bits) << 4) | (0xF & lane_bits));
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 301
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 302 /* release pma_xcvr_pllclk_en_ln_*, only for the master lane */
f61b3aed20003e drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 303 cdns_torrent_dp_write(cdns_phy, PHY_PMA_XCVR_PLLCLK_EN, 0x0001);
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 304
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 305 /* PHY PMA registers configuration functions */
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 306 /* Initialize PHY with max supported link rate, without SSC. */
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 307 if (cdns_phy->ref_clk_rate == REF_CLK_19_2MHz)
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 308 cdns_torrent_dp_pma_cmn_vco_cfg_19_2mhz(cdns_phy,
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 309 cdns_phy->max_bit_rate,
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 310 false);
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 311 else if (cdns_phy->ref_clk_rate == REF_CLK_25MHz)
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 312 cdns_torrent_dp_pma_cmn_vco_cfg_25mhz(cdns_phy,
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 313 cdns_phy->max_bit_rate,
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 314 false);
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 315 cdns_torrent_dp_pma_cmn_rate(cdns_phy, cdns_phy->max_bit_rate,
e4b496a376f1ad drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 316 cdns_phy->num_lanes);
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 317
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 318 /* take out of reset */
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 319 cdns_dp_phy_write_field(cdns_phy, PHY_RESET, 8, 1, 1);
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 320 ret = cdns_torrent_dp_wait_pma_cmn_ready(cdns_phy);
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 321 if (ret)
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 322 return ret;
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 323
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 324 ret = cdns_torrent_dp_run(cdns_phy);
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 325
21c79146a1bbc6 drivers/phy/cadence/phy-cadence-torrent.c Swapnil Jakhade 2020-02-06 @326 return ret;
c8b427edc7378f drivers/phy/cadence/phy-cadence-dp.c Scott Telford 2018-08-09 327 }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip