Skip to contentSkip to conversation

pinctrl: core: Handling pinmux and pinconf separately

bug report Dan Carpenter 2 participants 3 messages Mar 12, 2021 GPIO

lore
Share & tools
lore
#0 lore raw

Hello Michal Simek,

The patch 0952b7ec1614: "pinctrl: core: Handling pinmux and pinconf separately" from Mar 10, 2021, leads to the following static checker warning:

drivers/pinctrl/core.c:1275 pinctrl_commit_state()
error: uninitialized symbol 'ret'.

drivers/pinctrl/core.c
1239 static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state) 1240 {

  1241          struct pinctrl_setting *setting, *setting2;
  1242          struct pinctrl_state *old_state = p->state;
  1243          int ret;
  1244  
  1245          if (p->state) {
  1246                  /*
  1247                   * For each pinmux setting in the old state, forget SW's record
  1248                   * of mux owner for that pingroup. Any pingroups which are
  1249                   * still owned by the new state will be re-acquired by the call
  1250                   * to pinmux_enable_setting() in the loop below.
  1251                   */

1252 list_for_each_entry(setting, &p->state->settings, node) {
1253 if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
1254 continue;
1255 pinmux_disable_setting(setting);
1256 }
1257 }
1258
1259 p->state = NULL;
1260
1261 /* Apply all the settings for the new state - pinmux first */
1262 list_for_each_entry(setting, &state->settings, node) {
1263 switch (setting->type) {
1264 case PIN_MAP_TYPE_MUX_GROUP:
1265 ret = pinmux_enable_setting(setting);
1266 break;
1267 case PIN_MAP_TYPE_CONFIGS_PIN:
1268 case PIN_MAP_TYPE_CONFIGS_GROUP:
1269 break;

"ret" not set on these cases.

1270 default:
1271 ret = -EINVAL;
1272 break;
1273 }
1274
1275 if (ret < 0)
1276 goto unapply_new_state;
1277
1278 /* Do not link hogs (circular dependency) */
1279 if (p != setting->pctldev->p)

regards,
dan carpenter

#1 lore raw

It also complains about the next loop but that's a false positive because dealing with lists of data is tricky.

drivers/pinctrl/core.c:1297 pinctrl_commit_state() error: uninitialized symbol 'ret'.

I saw these two warnings initially from zero day bot but didn't forward it on because I only noticed the issue with second loop and not the first one. #LifeLessonOrSomething

regards,
dan carpenter

Quoted 57 lines · Dan Carpenter

Hello Michal Simek,

The patch 0952b7ec1614: "pinctrl: core: Handling pinmux and pinconf separately" from Mar 10, 2021, leads to the following static checker warning:

drivers/pinctrl/core.c:1275 pinctrl_commit_state()
error: uninitialized symbol 'ret'.

drivers/pinctrl/core.c
1239 static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state) 1240 {

  1241          struct pinctrl_setting *setting, *setting2;
  1242          struct pinctrl_state *old_state = p->state;
  1243          int ret;
  1244  
  1245          if (p->state) {
  1246                  /*
  1247                   * For each pinmux setting in the old state, forget SW's record
  1248                   * of mux owner for that pingroup. Any pingroups which are
  1249                   * still owned by the new state will be re-acquired by the call
  1250                   * to pinmux_enable_setting() in the loop below.
  1251                   */

1252 list_for_each_entry(setting, &p->state->settings, node) {
1253 if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
1254 continue;
1255 pinmux_disable_setting(setting);
1256 }
1257 }
1258
1259 p->state = NULL;
1260
1261 /* Apply all the settings for the new state - pinmux first */
1262 list_for_each_entry(setting, &state->settings, node) {
1263 switch (setting->type) {
1264 case PIN_MAP_TYPE_MUX_GROUP:
1265 ret = pinmux_enable_setting(setting);
1266 break;
1267 case PIN_MAP_TYPE_CONFIGS_PIN:
1268 case PIN_MAP_TYPE_CONFIGS_GROUP:
1269 break;

"ret" not set on these cases.

1270 default:
1271 ret = -EINVAL;
1272 break;
1273 }
1274
1275 if (ret < 0)
1276 goto unapply_new_state;
1277
1278 /* Do not link hogs (circular dependency) */
1279 if (p != setting->pctldev->p)

regards,
dan carpenter

#2 lore raw

Hi,

Quoted 8 lines · Dan Carpenter

It also complains about the next loop but that's a false positive because dealing with lists of data is tricky.

drivers/pinctrl/core.c:1297 pinctrl_commit_state() error: uninitialized symbol 'ret'.

I saw these two warnings initially from zero day bot but didn't forward it on because I only noticed the issue with second loop and not the first one. #LifeLessonOrSomething

It was reported by Colin yesterday. lore.kernel.org/r/[email protected]

Definitely thanks for report.

Thanks,
Michal