drivers/phy/cadence/phy-cadence-sierra.c:500 cdns_sierra_pll_mux_register() warn: passing zero to 'PTR_ERR'
PATCH 8404/9190 drivers/phy/cadence/phy-cadence-sierra.c:500 cdns_sierra_pll_mux_register() warn: passing zero to 'PTR_ERR'
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master head: 454c576c3f5e51d60f00a4ac0dde07f4f9d70e9d commit: 28081b72859f0fa3d5b56cfd84b2f5ba578765d2 [8404/9190] phy: cadence: Sierra: Model PLL_CMNLC and PLL_CMNLC1 as clocks (mux clocks) config: i386-randconfig-m021-20210401 (attached as .config) compiler: gcc-9 (Debian 9.3.0-22) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by kernel test robot <[email protected]>
Reported-by Dan Carpenter <[email protected]>
smatch warnings:drivers/phy/cadence/phy-cadence-sierra.c:500 cdns_sierra_pll_mux_register() warn: passing zero to 'PTR_ERR'
vim +/PTR_ERR +500 drivers/phy/cadence/phy-cadence-sierra.c
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 472 static int cdns_sierra_pll_mux_register(struct cdns_sierra_phy *sp,
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 473 struct regmap_field *pfdclk1_sel_field,
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 474 struct regmap_field *plllc1en_field,
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 475 struct regmap_field *termen_field,
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 476 int clk_index)
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 477 {
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 478 struct cdns_sierra_pll_mux *mux;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 479 struct device *dev = sp->dev;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 480 struct clk_init_data *init;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 481 const char **parent_names;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 482 unsigned int num_parents;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 483 char clk_name[100];
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 484 struct clk *clk;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 485 int i;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 486
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 487 mux = devm_kzalloc(dev, sizeof(*mux), GFP_KERNEL);
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 488 if (!mux)
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 489 return -ENOMEM;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 490
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 491 num_parents = SIERRA_NUM_CMN_PLLC_PARENTS;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 492 parent_names = devm_kzalloc(dev, (sizeof(char *) * num_parents), GFP_KERNEL);
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 493 if (!parent_names)
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 494 return -ENOMEM;
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 495
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 496 for (i = 0; i < num_parents; i++) {
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 497 clk = sp->input_clks[pll_mux_parent_index[clk_index][i]];
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 498 if (IS_ERR_OR_NULL(clk)) {
^^^^^^^^^^^^^^^^^^^
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 499 dev_err(dev, "No parent clock for derived_refclk\n");
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 @500 return PTR_ERR(clk);
^^^^^^^^^^^^Can "clk" really be NULL, and if it is then do we really want to return PTR_ERR(NULL) (which is zero/success)?
28081b72859f0f Kishon Vijay Abraham I 2021-03-19 501 } 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 502 parent_names[i] = __clk_get_name(clk); 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 503 } 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 504 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 505 snprintf(clk_name, sizeof(clk_name), "%s_%s", dev_name(dev), clk_names[clk_index]); 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 506 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 507 init = &mux->clk_data; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 508 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 509 init->ops = &cdns_sierra_pll_mux_ops; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 510 init->flags = CLK_SET_RATE_NO_REPARENT; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 511 init->parent_names = parent_names; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 512 init->num_parents = num_parents; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 513 init->name = clk_name; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 514 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 515 mux->pfdclk_sel_preg = pfdclk1_sel_field; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 516 mux->plllc1en_field = plllc1en_field; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 517 mux->termen_field = termen_field; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 518 mux->hw.init = init; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 519 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 520 clk = devm_clk_register(dev, &mux->hw); 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 521 if (IS_ERR(clk)) 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 522 return PTR_ERR(clk); 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 523 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 524 sp->output_clks[clk_index] = clk; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 525 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 526 return 0; 28081b72859f0f Kishon Vijay Abraham I 2021-03-19 527 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org