linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] soc/tegra: fuse: don't return -ENOMEM when allocate lookups failed
@ 2021-04-12 14:05 Yang Yingliang
  2021-06-01 17:02 ` Thierry Reding
  0 siblings, 1 reply; 2+ messages in thread
From: Yang Yingliang @ 2021-04-12 14:05 UTC (permalink / raw)
  To: linux-kernel, linux-tegra; +Cc: jonathanh, thierry.reding

fuse->base can not be unmapped if allocate lookups failed in
tegra_init_fuse(), because it is an early_initcall, the driver
will be loaded anyway and fuse->base will be accessed by other
functions later, so remove the return -ENOMEM after allocating
lookups failed to make less confusing.

Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
---
 drivers/soc/tegra/fuse/fuse-tegra.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/soc/tegra/fuse/fuse-tegra.c b/drivers/soc/tegra/fuse/fuse-tegra.c
index 94b60a692b51..a0def1219501 100644
--- a/drivers/soc/tegra/fuse/fuse-tegra.c
+++ b/drivers/soc/tegra/fuse/fuse-tegra.c
@@ -490,9 +490,15 @@ static int __init tegra_init_fuse(void)
 
 		fuse->lookups = kmemdup(fuse->soc->lookups, size, GFP_KERNEL);
 		if (!fuse->lookups)
-			return -ENOMEM;
-
-		nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
+			/*
+			 * fuse->base can not be unmapped if allocate lookups failed,
+			 * because it will be accessed by other functions later.
+			 * To make less confusing, remove the return -ENOMEM and
+			 * skip registering the nvmem cell lookups.
+			 */
+			pr_err("failed to allocate lookups");
+		else
+			nvmem_add_cell_lookups(fuse->lookups, fuse->soc->num_lookups);
 	}
 
 	return 0;
-- 
2.25.1


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

* Re: [PATCH -next] soc/tegra: fuse: don't return -ENOMEM when allocate lookups failed
  2021-04-12 14:05 [PATCH -next] soc/tegra: fuse: don't return -ENOMEM when allocate lookups failed Yang Yingliang
@ 2021-06-01 17:02 ` Thierry Reding
  0 siblings, 0 replies; 2+ messages in thread
From: Thierry Reding @ 2021-06-01 17:02 UTC (permalink / raw)
  To: Yang Yingliang; +Cc: linux-kernel, linux-tegra, jonathanh

[-- Attachment #1: Type: text/plain, Size: 712 bytes --]

On Mon, Apr 12, 2021 at 10:05:27PM +0800, Yang Yingliang wrote:
> fuse->base can not be unmapped if allocate lookups failed in
> tegra_init_fuse(), because it is an early_initcall, the driver
> will be loaded anyway and fuse->base will be accessed by other
> functions later, so remove the return -ENOMEM after allocating
> lookups failed to make less confusing.
> 
> Signed-off-by: Yang Yingliang <yangyingliang@huawei.com>
> ---
>  drivers/soc/tegra/fuse/fuse-tegra.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

Applied, though I did drop the error message. Out-of-memory situations
are noisy anyway, so the extra error message doesn't add anything.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2021-06-01 17:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-12 14:05 [PATCH -next] soc/tegra: fuse: don't return -ENOMEM when allocate lookups failed Yang Yingliang
2021-06-01 17:02 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).