there is a warning saying variable dereferenced before check 'data->notifier' in line 828. add "for(data->notifier)" before variable deferenced. Signed-off-by: Yu Sun <u202112062@xxxxxxxxxxx> Reviewed-by: Dongliang Mu <dzm91@xxxxxxxxxxx> Reviewed-by: Dan Carpenter <error27@xxxxxxxxx> --- drivers/platform/mellanox/mlxreg-lc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/platform/mellanox/mlxreg-lc.c b/drivers/platform/mellanox/mlxreg-lc.c index 43d119e3a473..e92add40750b 100644 --- a/drivers/platform/mellanox/mlxreg-lc.c +++ b/drivers/platform/mellanox/mlxreg-lc.c @@ -824,9 +824,12 @@ static int mlxreg_lc_probe(struct platform_device *pdev) return -ENOMEM; mutex_init(&mlxreg_lc->lock); - /* Set event notification callback. */ - data->notifier->user_handler = mlxreg_lc_event_handler; - data->notifier->handle = mlxreg_lc; + + if (data->notifier) { + /* Set event notification callback. */ + data->notifier->user_handler = mlxreg_lc_event_handler; + data->notifier->handle = mlxreg_lc; + } data->hpdev.adapter = i2c_get_adapter(data->hpdev.nr); if (!data->hpdev.adapter) { -- 2.42.0