All of lore.kernel.org
 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 related	[flat|nested] 4+ messages in thread

* Re: [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
  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
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Carpenter @ 2023-11-30 11:47 UTC (permalink / raw)
  To: Yu Sun
  Cc: Hans de Goede, Ilpo Järvinen, Mark Gross, Vadim Pasternak,
	hust-os-kernel-patches, Dongliang Mu, Dan Carpenter,
	platform-driver-x86, linux-kernel

On Thu, Nov 30, 2023 at 05:44:07PM +0800, Yu Sun wrote:
> there is a warning saying variable dereferenced before
> check 'data->notifier' in line 828.
> add "for(data->notifier)" before variable deferenced.
       ^^^
Should have been "if (data->notifier)".

> 
> Signed-off-by: Yu Sun <u202112062@hust.edu.cn>
> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> Reviewed-by: Dan Carpenter <error27@gmail.com>

I didn't really explicitly give a Reviewed-by tag for this patch.
https://groups.google.com/g/hust-os-kernel-patches/c/c5hUaYIDcII/m/h4aFS7PkCQAJ
I also said that I thought it looked correct but that it needed a Fixes:
tag however the Fixes tag I suggested was wrong.

Looking at it now, the correct Fixes tag would be:
Fixes: 1c8ee06b637f ("platform/mellanox: Remove unnecessary code")

That commit says that the NULL check is not required.  So now I'm
confused.  On the one hand, the impulse is to trust the maintainer, but
on the other hand my review suggested that the NULL check might be
required.

regards,
dan carpenter



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

* RE: [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
  2023-11-30 11:47 ` Dan Carpenter
@ 2023-11-30 16:24   ` Vadim Pasternak
  2023-12-02 11:39     ` Hans de Goede
  0 siblings, 1 reply; 4+ messages in thread
From: Vadim Pasternak @ 2023-11-30 16:24 UTC (permalink / raw)
  To: Dan Carpenter, Yu Sun
  Cc: Hans de Goede, Ilpo Järvinen, Mark Gross,
	hust-os-kernel-patches, Dongliang Mu, Dan Carpenter,
	platform-driver-x86, linux-kernel

Hi Dan,

> -----Original Message-----
> From: Dan Carpenter <dan.carpenter@linaro.org>
> Sent: Thursday, 30 November 2023 13:47
> To: Yu Sun <u202112062@hust.edu.cn>
> Cc: Hans de Goede <hdegoede@redhat.com>; Ilpo Järvinen
> <ilpo.jarvinen@linux.intel.com>; Mark Gross <markgross@kernel.org>; Vadim
> Pasternak <vadimp@nvidia.com>; hust-os-kernel-
> patches@googlegroups.com; Dongliang Mu <dzm91@hust.edu.cn>; Dan
> Carpenter <error27@gmail.com>; platform-driver-x86@vger.kernel.org; linux-
> kernel@vger.kernel.org
> Subject: Re: [PATCH] platform/mellanox: mlxreg-lc: Check before variable
> dereferenced
> 
> On Thu, Nov 30, 2023 at 05:44:07PM +0800, Yu Sun wrote:
> > there is a warning saying variable dereferenced before check
> > 'data->notifier' in line 828.
> > add "for(data->notifier)" before variable deferenced.
>        ^^^
> Should have been "if (data->notifier)".
> 
> >
> > Signed-off-by: Yu Sun <u202112062@hust.edu.cn>
> > Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
> > Reviewed-by: Dan Carpenter <error27@gmail.com>
> 
> I didn't really explicitly give a Reviewed-by tag for this patch.
> https://groups.google.com/g/hust-os-kernel-
> patches/c/c5hUaYIDcII/m/h4aFS7PkCQAJ
> I also said that I thought it looked correct but that it needed a Fixes:
> tag however the Fixes tag I suggested was wrong.
> 
> Looking at it now, the correct Fixes tag would be:
> Fixes: 1c8ee06b637f ("platform/mellanox: Remove unnecessary code")
> 
> That commit says that the NULL check is not required.  So now I'm confused.
> On the one hand, the impulse is to trust the maintainer, but on the other hand
> my review suggested that the NULL check might be required.

Yes, it indeed required.
My mistake.

Thank you for your comments.

> 
> regards,
> dan carpenter
> 


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

* Re: [PATCH] platform/mellanox: mlxreg-lc: Check before variable dereferenced
  2023-11-30 16:24   ` Vadim Pasternak
@ 2023-12-02 11:39     ` Hans de Goede
  0 siblings, 0 replies; 4+ messages in thread
From: Hans de Goede @ 2023-12-02 11:39 UTC (permalink / raw)
  To: Vadim Pasternak, Dan Carpenter, Yu Sun
  Cc: Ilpo Järvinen, Mark Gross, hust-os-kernel-patches,
	Dongliang Mu, Dan Carpenter, platform-driver-x86, linux-kernel

Hi,

On 11/30/23 17:24, Vadim Pasternak wrote:
> Hi Dan,
> 
>> -----Original Message-----
>> From: Dan Carpenter <dan.carpenter@linaro.org>
>> Sent: Thursday, 30 November 2023 13:47
>> To: Yu Sun <u202112062@hust.edu.cn>
>> Cc: Hans de Goede <hdegoede@redhat.com>; Ilpo Järvinen
>> <ilpo.jarvinen@linux.intel.com>; Mark Gross <markgross@kernel.org>; Vadim
>> Pasternak <vadimp@nvidia.com>; hust-os-kernel-
>> patches@googlegroups.com; Dongliang Mu <dzm91@hust.edu.cn>; Dan
>> Carpenter <error27@gmail.com>; platform-driver-x86@vger.kernel.org; linux-
>> kernel@vger.kernel.org
>> Subject: Re: [PATCH] platform/mellanox: mlxreg-lc: Check before variable
>> dereferenced
>>
>> On Thu, Nov 30, 2023 at 05:44:07PM +0800, Yu Sun wrote:
>>> there is a warning saying variable dereferenced before check
>>> 'data->notifier' in line 828.
>>> add "for(data->notifier)" before variable deferenced.
>>        ^^^
>> Should have been "if (data->notifier)".
>>
>>>
>>> Signed-off-by: Yu Sun <u202112062@hust.edu.cn>
>>> Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
>>> Reviewed-by: Dan Carpenter <error27@gmail.com>
>>
>> I didn't really explicitly give a Reviewed-by tag for this patch.
>> https://groups.google.com/g/hust-os-kernel-
>> patches/c/c5hUaYIDcII/m/h4aFS7PkCQAJ
>> I also said that I thought it looked correct but that it needed a Fixes:
>> tag however the Fixes tag I suggested was wrong.
>>
>> Looking at it now, the correct Fixes tag would be:
>> Fixes: 1c8ee06b637f ("platform/mellanox: Remove unnecessary code")
>>
>> That commit says that the NULL check is not required.  So now I'm confused.
>> On the one hand, the impulse is to trust the maintainer, but on the other hand
>> my review suggested that the NULL check might be required.
> 
> Yes, it indeed required.
> My mistake.

Ok, so we are going to need a v2 of this addressing Dan's remarks
about the commit message.

Yu Sun, can you please submit a new version addressing
Dan's comments on the commit message ?

Regards,

Hans



^ 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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.