public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
@ 2023-06-09  1:48 Jiasheng Jiang
  2023-06-09  6:38 ` Lee Jones
  2023-11-24 17:47 ` Andy Shevchenko
  0 siblings, 2 replies; 6+ messages in thread
From: Jiasheng Jiang @ 2023-06-09  1:48 UTC (permalink / raw)
  To: lee; +Cc: linux-kernel, Jiasheng Jiang

Add the missing check for platform_get_resource and return error
if it fails.

Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
Changelog:

v1 -> v2:

1. Replace "-ENOMEM" with "-ENODEV".
---
 drivers/mfd/intel-lpss-acpi.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/mfd/intel-lpss-acpi.c b/drivers/mfd/intel-lpss-acpi.c
index a143c8dca2d9..212818aef93e 100644
--- a/drivers/mfd/intel-lpss-acpi.c
+++ b/drivers/mfd/intel-lpss-acpi.c
@@ -183,6 +183,9 @@ static int intel_lpss_acpi_probe(struct platform_device *pdev)
 		return -ENOMEM;
 
 	info->mem = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!info->mem)
+		return -ENODEV;
+
 	info->irq = platform_get_irq(pdev, 0);
 
 	ret = intel_lpss_probe(&pdev->dev, info);
-- 
2.25.1


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

* Re: [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
  2023-06-09  1:48 [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource Jiasheng Jiang
@ 2023-06-09  6:38 ` Lee Jones
  2023-11-24 17:47 ` Andy Shevchenko
  1 sibling, 0 replies; 6+ messages in thread
From: Lee Jones @ 2023-06-09  6:38 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: linux-kernel

On Fri, 09 Jun 2023, Jiasheng Jiang wrote:

> Add the missing check for platform_get_resource and return error
> if it fails.
> 
> Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> Changelog:
> 
> v1 -> v2:
> 
> 1. Replace "-ENOMEM" with "-ENODEV".
> ---
>  drivers/mfd/intel-lpss-acpi.c | 3 +++
>  1 file changed, 3 insertions(+)

Applied, thanks

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
  2023-06-09  1:48 [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource Jiasheng Jiang
  2023-06-09  6:38 ` Lee Jones
@ 2023-11-24 17:47 ` Andy Shevchenko
  2023-11-27  8:53   ` Lee Jones
  1 sibling, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-11-24 17:47 UTC (permalink / raw)
  To: Jiasheng Jiang; +Cc: lee, linux-kernel

On Fri, Jun 09, 2023 at 09:48:18AM +0800, Jiasheng Jiang wrote:
> Add the missing check for platform_get_resource and return error
> if it fails.

> Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")

This does not fix anything and just introduces a duplication code.
I would like this to be reverted. Should I send one?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
  2023-11-24 17:47 ` Andy Shevchenko
@ 2023-11-27  8:53   ` Lee Jones
  2023-11-27 12:50     ` Andy Shevchenko
  0 siblings, 1 reply; 6+ messages in thread
From: Lee Jones @ 2023-11-27  8:53 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Jiasheng Jiang, linux-kernel

On Fri, 24 Nov 2023, Andy Shevchenko wrote:

> On Fri, Jun 09, 2023 at 09:48:18AM +0800, Jiasheng Jiang wrote:
> > Add the missing check for platform_get_resource and return error
> > if it fails.
> 
> > Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
> 
> This does not fix anything and just introduces a duplication code.
> I would like this to be reverted. Should I send one?

Checking this value at the source of obtention and providing and earlier
return with arguably a better return value, all at the cost of an
inexpensive pointer comparison to NULL doesn't sound like a terrible
idea.

If you were committed to the idea of removing it, which I suggest you
reconsider, I would insist that you replace it with at least a comment.

-- 
Lee Jones [李琼斯]

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

* Re: [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
  2023-11-27  8:53   ` Lee Jones
@ 2023-11-27 12:50     ` Andy Shevchenko
  2023-11-30 11:35       ` Lee Jones
  0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2023-11-27 12:50 UTC (permalink / raw)
  To: Lee Jones; +Cc: Jiasheng Jiang, linux-kernel

On Mon, Nov 27, 2023 at 08:53:56AM +0000, Lee Jones wrote:
> On Fri, 24 Nov 2023, Andy Shevchenko wrote:
> > On Fri, Jun 09, 2023 at 09:48:18AM +0800, Jiasheng Jiang wrote:

...

> > > Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
> > 
> > This does not fix anything and just introduces a duplication code.
> > I would like this to be reverted. Should I send one?
> 
> Checking this value at the source of obtention and providing and earlier
> return with arguably a better return value, all at the cost of an
> inexpensive pointer comparison to NULL doesn't sound like a terrible
> idea.

In general, I agree with you, but the cases similar to this. Why?
Because memory resource retrieval and remapping has a lot of helpers,
some of which are enriched with own error handling and messaging.

Yes, we use devm_ioremap_uc(), which doesn't give that (yet?).
However, it will be more work if we, theoretically, switch to
something like devm_ioremap_resource() in the future.

Hence, I would like to have a common code to be in common place
and behave in the same way independently on the glue druver (PCI,
ACPI, etc).

> If you were committed to the idea of removing it, which I suggest you
> reconsider, I would insist that you replace it with at least a comment.

Isn't what I have done in the series I sent last week?

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource
  2023-11-27 12:50     ` Andy Shevchenko
@ 2023-11-30 11:35       ` Lee Jones
  0 siblings, 0 replies; 6+ messages in thread
From: Lee Jones @ 2023-11-30 11:35 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: Jiasheng Jiang, linux-kernel

On Mon, 27 Nov 2023, Andy Shevchenko wrote:

> On Mon, Nov 27, 2023 at 08:53:56AM +0000, Lee Jones wrote:
> > On Fri, 24 Nov 2023, Andy Shevchenko wrote:
> > > On Fri, Jun 09, 2023 at 09:48:18AM +0800, Jiasheng Jiang wrote:
> 
> ...
> 
> > > > Fixes: 4b45efe85263 ("mfd: Add support for Intel Sunrisepoint LPSS devices")
> > > 
> > > This does not fix anything and just introduces a duplication code.
> > > I would like this to be reverted. Should I send one?
> > 
> > Checking this value at the source of obtention and providing and earlier
> > return with arguably a better return value, all at the cost of an
> > inexpensive pointer comparison to NULL doesn't sound like a terrible
> > idea.
> 
> In general, I agree with you, but the cases similar to this. Why?
> Because memory resource retrieval and remapping has a lot of helpers,
> some of which are enriched with own error handling and messaging.
> 
> Yes, we use devm_ioremap_uc(), which doesn't give that (yet?).
> However, it will be more work if we, theoretically, switch to
> something like devm_ioremap_resource() in the future.
> 
> Hence, I would like to have a common code to be in common place
> and behave in the same way independently on the glue druver (PCI,
> ACPI, etc).
> 
> > If you were committed to the idea of removing it, which I suggest you
> > reconsider, I would insist that you replace it with at least a comment.
> 
> Isn't what I have done in the series I sent last week?

You have to send links when you say things like this.

Last week I had 1000 unread upstream mails in this inbox.

-- 
Lee Jones [李琼斯]

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

end of thread, other threads:[~2023-11-30 11:35 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-09  1:48 [PATCH v2] mfd: intel-lpss: Add missing check for platform_get_resource Jiasheng Jiang
2023-06-09  6:38 ` Lee Jones
2023-11-24 17:47 ` Andy Shevchenko
2023-11-27  8:53   ` Lee Jones
2023-11-27 12:50     ` Andy Shevchenko
2023-11-30 11:35       ` Lee Jones

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