Skip to contentSkip to conversation

PM / devfreq: Remove redundant governor_name from struct devfreq

bug report Dan Carpenter 1 participant 2 messages Jul 7, 2021

lore
Share & tools
lore
#0 lore raw

[ It's so weird that I never reported this and also that no one else
seems to have fixed it... ]

Hello Chanwoo Choi,

This is a semi-automatic email about new static checker warnings.

The patch 96ffcdf239de: "PM / devfreq: Remove redundant governor_name from struct devfreq" from Oct 20, 2020, leads to the following Smatch complaint:

    drivers/devfreq/devfreq.c:1272 devfreq_add_governor()
    warn: variable dereferenced before check 'devfreq->governor' (see line 1269)

drivers/devfreq/devfreq.c
1268
1269 if (!strncmp(devfreq->governor->name, governor->name,

                                     ^^^^^^^^^^^^^^^^^^^^^^^^

Dereference

1270 DEVFREQ_NAME_LEN)) {
1271 /* The following should never occur */

                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

What?!?

  1272				if (devfreq->governor) {
                                    ^^^^^^^^^^^^^^^^^

Checked too late.

1273 dev_warn(dev,
1274 "%s: Governor %s already present\n",

regards,
dan carpenter

#1 lore raw

Same thing in the remove function as well.

    drivers/devfreq/devfreq.c:1334 devfreq_remove_governor()
    warn: variable dereferenced before check 'devfreq->governor' (see line 1331)

regards,
dan carpenter