public inbox for linux-gpio@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev, Krzysztof Kozlowski <krzk@kernel.org>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
	linux-gpio@vger.kernel.org, Linus Walleij <linusw@kernel.org>,
	Heiko Stuebner <heiko@sntech.de>
Subject: [linusw-pinctrl:devel 30/31] drivers/pinctrl/pinctrl-rockchip.c:3683 rockchip_pinconf_set() error: we previously assumed 'gpio->direction_output' could be null (see line 3644)
Date: Tue, 20 Jan 2026 09:25:00 +0300	[thread overview]
Message-ID: <202601200057.P0Lr7NDg-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl.git devel
head:   76d415763bae9488dd2b923b1348ce6f26c1f0ae
commit: e2c58cbe3aff49fe201e81ee5f651294e313ec74 [30/31] pinctrl: rockchip: Simplify locking with scoped_guard()
config: sh-randconfig-r073-20260119 (https://download.01.org/0day-ci/archive/20260120/202601200057.P0Lr7NDg-lkp@intel.com/config)
compiler: sh4-linux-gcc (GCC) 15.2.0
smatch version: v0.5.0-8985-g2614ff1a

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: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202601200057.P0Lr7NDg-lkp@intel.com/

smatch warnings:
drivers/pinctrl/pinctrl-rockchip.c:3683 rockchip_pinconf_set() error: we previously assumed 'gpio->direction_output' could be null (see line 3644)

vim +3683 drivers/pinctrl/pinctrl-rockchip.c

d3e5116119bd02e Heiko Stübner       2013-06-10  3622  static int rockchip_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,
03b054e9696c3cb Sherman Yin         2013-08-27  3623  				unsigned long *configs, unsigned num_configs)
d3e5116119bd02e Heiko Stübner       2013-06-10  3624  {
d3e5116119bd02e Heiko Stübner       2013-06-10  3625  	struct rockchip_pinctrl *info = pinctrl_dev_get_drvdata(pctldev);
d3e5116119bd02e Heiko Stübner       2013-06-10  3626  	struct rockchip_pin_bank *bank = pin_to_bank(info, pin);
9ce9a02039de72e Jianqun Xu          2021-08-16  3627  	struct gpio_chip *gpio = &bank->gpio_chip;
03b054e9696c3cb Sherman Yin         2013-08-27  3628  	enum pin_config_param param;
58957d2edfa19e9 Mika Westerberg     2017-01-23  3629  	u32 arg;
03b054e9696c3cb Sherman Yin         2013-08-27  3630  	int i;
03b054e9696c3cb Sherman Yin         2013-08-27  3631  	int rc;
03b054e9696c3cb Sherman Yin         2013-08-27  3632  
03b054e9696c3cb Sherman Yin         2013-08-27  3633  	for (i = 0; i < num_configs; i++) {
03b054e9696c3cb Sherman Yin         2013-08-27  3634  		param = pinconf_to_config_param(configs[i]);
03b054e9696c3cb Sherman Yin         2013-08-27  3635  		arg = pinconf_to_config_argument(configs[i]);
d3e5116119bd02e Heiko Stübner       2013-06-10  3636  
203a83112e097a5 Linus Walleij       2025-09-05  3637  		if (param == PIN_CONFIG_LEVEL || param == PIN_CONFIG_INPUT_ENABLE) {
8ce5ef645468502 Caleb Connolly      2022-03-28  3638  			/*
8ce5ef645468502 Caleb Connolly      2022-03-28  3639  			 * Check for gpio driver not being probed yet.
8ce5ef645468502 Caleb Connolly      2022-03-28  3640  			 * The lock makes sure that either gpio-probe has completed
8ce5ef645468502 Caleb Connolly      2022-03-28  3641  			 * or the gpio driver hasn't probed yet.
8ce5ef645468502 Caleb Connolly      2022-03-28  3642  			 */
e2c58cbe3aff49f Krzysztof Kozlowski 2026-01-18  3643  			scoped_guard(mutex, &bank->deferred_lock) {
8ce5ef645468502 Caleb Connolly      2022-03-28 @3644  				if (!gpio || !gpio->direction_output) {
                                                                                              ^^^^^^^^^^^^^^^^^^^^^^
Is this check necessary?

e2c58cbe3aff49f Krzysztof Kozlowski 2026-01-18  3645  					rc = rockchip_pinconf_defer_pin(bank,
e2c58cbe3aff49f Krzysztof Kozlowski 2026-01-18  3646  									pin - bank->pin_base,
e2c58cbe3aff49f Krzysztof Kozlowski 2026-01-18  3647  									param, arg);
8ce5ef645468502 Caleb Connolly      2022-03-28  3648  					if (rc)
8ce5ef645468502 Caleb Connolly      2022-03-28  3649  						return rc;
8ce5ef645468502 Caleb Connolly      2022-03-28  3650  					break;
8ce5ef645468502 Caleb Connolly      2022-03-28  3651  				}
e2c58cbe3aff49f Krzysztof Kozlowski 2026-01-18  3652  			}
8ce5ef645468502 Caleb Connolly      2022-03-28  3653  		}
8ce5ef645468502 Caleb Connolly      2022-03-28  3654  
d3e5116119bd02e Heiko Stübner       2013-06-10  3655  		switch (param) {
d3e5116119bd02e Heiko Stübner       2013-06-10  3656  		case PIN_CONFIG_BIAS_DISABLE:
03b054e9696c3cb Sherman Yin         2013-08-27  3657  			rc =  rockchip_set_pull(bank, pin - bank->pin_base,
03b054e9696c3cb Sherman Yin         2013-08-27  3658  				param);
03b054e9696c3cb Sherman Yin         2013-08-27  3659  			if (rc)
03b054e9696c3cb Sherman Yin         2013-08-27  3660  				return rc;
44b6d93043ab677 Heiko Stübner       2013-06-16  3661  			break;
d3e5116119bd02e Heiko Stübner       2013-06-10  3662  		case PIN_CONFIG_BIAS_PULL_UP:
d3e5116119bd02e Heiko Stübner       2013-06-10  3663  		case PIN_CONFIG_BIAS_PULL_DOWN:
d3e5116119bd02e Heiko Stübner       2013-06-10  3664  		case PIN_CONFIG_BIAS_PULL_PIN_DEFAULT:
6ca5274d1d1258b Heiko Stübner       2013-10-16  3665  		case PIN_CONFIG_BIAS_BUS_HOLD:
44b6d93043ab677 Heiko Stübner       2013-06-16  3666  			if (!rockchip_pinconf_pull_valid(info->ctrl, param))
44b6d93043ab677 Heiko Stübner       2013-06-16  3667  				return -ENOTSUPP;
44b6d93043ab677 Heiko Stübner       2013-06-16  3668  
44b6d93043ab677 Heiko Stübner       2013-06-16  3669  			if (!arg)
44b6d93043ab677 Heiko Stübner       2013-06-16  3670  				return -EINVAL;
44b6d93043ab677 Heiko Stübner       2013-06-16  3671  
03b054e9696c3cb Sherman Yin         2013-08-27  3672  			rc = rockchip_set_pull(bank, pin - bank->pin_base,
03b054e9696c3cb Sherman Yin         2013-08-27  3673  				param);
03b054e9696c3cb Sherman Yin         2013-08-27  3674  			if (rc)
03b054e9696c3cb Sherman Yin         2013-08-27  3675  				return rc;
d3e5116119bd02e Heiko Stübner       2013-06-10  3676  			break;
203a83112e097a5 Linus Walleij       2025-09-05  3677  		case PIN_CONFIG_LEVEL:
9ce9a02039de72e Jianqun Xu          2021-08-16  3678  			rc = rockchip_set_mux(bank, pin - bank->pin_base,
9ce9a02039de72e Jianqun Xu          2021-08-16  3679  					      RK_FUNC_GPIO);
9ce9a02039de72e Jianqun Xu          2021-08-16  3680  			if (rc != RK_FUNC_GPIO)
9ce9a02039de72e Jianqun Xu          2021-08-16  3681  				return -EINVAL;
9ce9a02039de72e Jianqun Xu          2021-08-16  3682  
9ce9a02039de72e Jianqun Xu          2021-08-16 @3683  			rc = gpio->direction_output(gpio, pin - bank->pin_base,
                                                                             ^^^^^^^^^^^^^^^^^^^^^^
Unchecked dereference.  This is old code so it's presumably okay.  I
think this warning is triggering now because of changes in Smatch.

9ce9a02039de72e Jianqun Xu          2021-08-16  3684  						    arg);
a076e2ed3fd26f8 Heiko Stübner       2014-04-23  3685  			if (rc)
a076e2ed3fd26f8 Heiko Stübner       2014-04-23  3686  				return rc;
a076e2ed3fd26f8 Heiko Stübner       2014-04-23  3687  			break;
42d90a1e5caf731 Caleb Connolly      2022-03-28  3688  		case PIN_CONFIG_INPUT_ENABLE:
42d90a1e5caf731 Caleb Connolly      2022-03-28  3689  			rc = rockchip_set_mux(bank, pin - bank->pin_base,
42d90a1e5caf731 Caleb Connolly      2022-03-28  3690  					      RK_FUNC_GPIO);
42d90a1e5caf731 Caleb Connolly      2022-03-28  3691  			if (rc != RK_FUNC_GPIO)
42d90a1e5caf731 Caleb Connolly      2022-03-28  3692  				return -EINVAL;
42d90a1e5caf731 Caleb Connolly      2022-03-28  3693  
42d90a1e5caf731 Caleb Connolly      2022-03-28  3694  			rc = gpio->direction_input(gpio, pin - bank->pin_base);
42d90a1e5caf731 Caleb Connolly      2022-03-28  3695  			if (rc)
42d90a1e5caf731 Caleb Connolly      2022-03-28  3696  				return rc;
42d90a1e5caf731 Caleb Connolly      2022-03-28  3697  			break;
b547c8007e83a47 Heiko Stübner       2014-07-20  3698  		case PIN_CONFIG_DRIVE_STRENGTH:
b547c8007e83a47 Heiko Stübner       2014-07-20  3699  			/* rk3288 is the first with per-pin drive-strength */
ef17f69f5bf57de Heiko Stübner       2015-06-12  3700  			if (!info->ctrl->drv_calc_reg)
b547c8007e83a47 Heiko Stübner       2014-07-20  3701  				return -ENOTSUPP;
b547c8007e83a47 Heiko Stübner       2014-07-20  3702  
ef17f69f5bf57de Heiko Stübner       2015-06-12  3703  			rc = rockchip_set_drive_perpin(bank,
ef17f69f5bf57de Heiko Stübner       2015-06-12  3704  						pin - bank->pin_base, arg);
b547c8007e83a47 Heiko Stübner       2014-07-20  3705  			if (rc < 0)
b547c8007e83a47 Heiko Stübner       2014-07-20  3706  				return rc;
b547c8007e83a47 Heiko Stübner       2014-07-20  3707  			break;
e3b357d7dfe6b38 david.wu            2017-03-02  3708  		case PIN_CONFIG_INPUT_SCHMITT_ENABLE:
e3b357d7dfe6b38 david.wu            2017-03-02  3709  			if (!info->ctrl->schmitt_calc_reg)
e3b357d7dfe6b38 david.wu            2017-03-02  3710  				return -ENOTSUPP;
e3b357d7dfe6b38 david.wu            2017-03-02  3711  
e3b357d7dfe6b38 david.wu            2017-03-02  3712  			rc = rockchip_set_schmitt(bank,
e3b357d7dfe6b38 david.wu            2017-03-02  3713  						  pin - bank->pin_base, arg);
e3b357d7dfe6b38 david.wu            2017-03-02  3714  			if (rc < 0)
e3b357d7dfe6b38 david.wu            2017-03-02  3715  				return rc;
e3b357d7dfe6b38 david.wu            2017-03-02  3716  			break;
d3e5116119bd02e Heiko Stübner       2013-06-10  3717  		default:
d3e5116119bd02e Heiko Stübner       2013-06-10  3718  			return -ENOTSUPP;
d3e5116119bd02e Heiko Stübner       2013-06-10  3719  			break;
d3e5116119bd02e Heiko Stübner       2013-06-10  3720  		}
03b054e9696c3cb Sherman Yin         2013-08-27  3721  	} /* for each config */
d3e5116119bd02e Heiko Stübner       2013-06-10  3722  
d3e5116119bd02e Heiko Stübner       2013-06-10  3723  	return 0;
d3e5116119bd02e Heiko Stübner       2013-06-10  3724  }

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


             reply	other threads:[~2026-01-20  6:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20  6:25 Dan Carpenter [this message]
2026-01-22 18:23 ` [linusw-pinctrl:devel 30/31] drivers/pinctrl/pinctrl-rockchip.c:3683 rockchip_pinconf_set() error: we previously assumed 'gpio->direction_output' could be null (see line 3644) Heiko Stuebner

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=202601200057.P0Lr7NDg-lkp@intel.com \
    --to=dan.carpenter@linaro.org \
    --cc=heiko@sntech.de \
    --cc=krzk@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=oe-kbuild@lists.linux.dev \
    /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