From: Yu Sun <u202112062@hust.edu.cn>
To: "Hans de Goede" <hdegoede@redhat.com>,
"Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>,
"Mark Gross" <markgross@kernel.org>,
"Vadim Pasternak" <vadimp@nvidia.com>
Cc: hust-os-kernel-patches@googlegroups.com,
Yu Sun <u202112062@hust.edu.cn>, Dongliang Mu <dzm91@hust.edu.cn>,
Dan Carpenter <error27@gmail.com>,
platform-driver-x86@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
Date: Thu, 30 Nov 2023 17:44:07 +0800 [thread overview]
Message-ID: <20231130094409.3963-1-u202112062@hust.edu.cn> (raw)
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
next reply other threads:[~2023-11-30 9:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-30 9:44 Yu Sun [this message]
2023-11-30 11:47 ` Dan Carpenter
2023-11-30 16:24 ` Vadim Pasternak
2023-12-02 11:39 ` Hans de Goede
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231130094409.3963-1-u202112062@hust.edu.cn \
--to=u202112062@hust.edu.cn \
--cc=dzm91@hust.edu.cn \
--cc=error27@gmail.com \
--cc=hdegoede@redhat.com \
--cc=hust-os-kernel-patches@googlegroups.com \
--cc=ilpo.jarvinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=markgross@kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=vadimp@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®