mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
@ 2023-11-30  9:44 Yu Sun
  2023-11-30 11:47 ` Dan Carpenter
  0 siblings, 1 reply; 4+ messages in thread
From: Yu Sun @ 2023-11-30  9:44 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen, Mark Gross, Vadim Pasternak
  Cc: hust-os-kernel-patches, Yu Sun, Dongliang Mu, Dan Carpenter,
	platform-driver-x86, linux-kernel

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@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Reviewed-by: Dan Carpenter <error27@gmail.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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-02 11:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-30  9:44 [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced Yu Sun
2023-11-30 11:47 ` Dan Carpenter
2023-11-30 16:24   ` Vadim Pasternak
2023-12-02 11:39     ` Hans de Goede

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®