Skip to contentSkip to conversation

mlxreg_lc_probe() warn: variable dereferenced before check

DISCUSSION Hans de Goede 1 participant 1 message Sep 11, 2022 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

Hi Vadim,

The kernel test robot pointed me to the following warning in my tree:

drivers/platform/mellanox/mlxreg-lc.c:903 mlxreg_lc_probe() warn: variable dereferenced before check 'data->notifier' (see line 828)

I took a quick peek and data comes from:

        data = dev_get_platdata(&pdev->dev);

And then indeed after that if data != NULL data-> notifiers gets derefenced unconditionally in the normal code path:

        /* Set event notification callback. */
        data->notifier->user_handler = mlxreg_lc_event_handler;
        data->notifier->handle = mlxreg_lc;

Where as the error exit path has:

        /* Clear event notification callback and handle. */
        if (data->notifier) {
                data->notifier->user_handler = NULL;
                data->notifier->handle = NULL;
        }

It seems to me that either both uses of data->notifier need a check; or none of the two uses of data->notifier need a check ?

Can you take a look at this please? (and cook up a patch ?)

Regards,

Hans