[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20231130094409.3963-1-u202112062@hust.edu.cn>
Date: Thu, 30 Nov 2023 17:44:07 +0800
From: Yu Sun <u202112062@...t.edu.cn>
To: Hans de Goede <hdegoede@...hat.com>,
Ilpo Järvinen <ilpo.jarvinen@...ux.intel.com>,
Mark Gross <markgross@...nel.org>,
Vadim Pasternak <vadimp@...dia.com>
Cc: hust-os-kernel-patches@...glegroups.com,
Yu Sun <u202112062@...t.edu.cn>,
Dongliang Mu <dzm91@...t.edu.cn>,
Dan Carpenter <error27@...il.com>,
platform-driver-x86@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
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@...t.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@...t.edu.cn>
Reviewed-by: Dan Carpenter <error27@...il.com>
---
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
Powered by blists - more mailing lists