All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] nvmem: brcm_nvram: check for allocation failure
@ 2022-05-20  6:45 Dan Carpenter
  2022-05-20  7:59 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-05-20  6:45 UTC (permalink / raw)
  To: gregkh
  Cc: linux-kernel, Dan Carpenter, stable, Rafał Miłecki,
	Srinivas Kandagatla

Check for if the kcalloc() fails.

Cc: stable@vger.kernel.org
Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rafał Miłecki <rafal@milecki.pl>
Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
---
v3: Update fixes tag
v2: I don't think anything changed in v2?  Added tags?

 drivers/nvmem/brcm_nvram.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
index 450b927691c3..48bb8c62cbbf 100644
--- a/drivers/nvmem/brcm_nvram.c
+++ b/drivers/nvmem/brcm_nvram.c
@@ -97,6 +97,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
 	len = le32_to_cpu(header.len);
 
 	data = kcalloc(1, len, GFP_KERNEL);
+	if (!data)
+		return -ENOMEM;
 	memcpy_fromio(data, priv->base, len);
 	data[len - 1] = '\0';
 
-- 
2.21.0

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

* Re: [PATCH v3] nvmem: brcm_nvram: check for allocation failure
  2022-05-20  6:45 [PATCH v3] nvmem: brcm_nvram: check for allocation failure Dan Carpenter
@ 2022-05-20  7:59 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2022-05-20  7:59 UTC (permalink / raw)
  To: Dan Carpenter, gregkh
  Cc: linux-kernel, stable, Rafał Miłecki, Srinivas Kandagatla

On Fri, 2022-05-20 at 09:45 +0300, Dan Carpenter wrote:
> Check for if the kcalloc() fails.
> 
> Cc: stable@vger.kernel.org
> Fixes: 6e977eaa8280 ("nvmem: brcm_nvram: parse NVRAM content into NVMEM cells")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> Acked-by: Rafał Miłecki <rafal@milecki.pl>
> Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
> ---
> v3: Update fixes tag
> v2: I don't think anything changed in v2?  Added tags?
[]
> diff --git a/drivers/nvmem/brcm_nvram.c b/drivers/nvmem/brcm_nvram.c
[]
> @@ -97,6 +97,8 @@ static int brcm_nvram_parse(struct brcm_nvram *priv)
>  	len = le32_to_cpu(header.len);
>  
>  	data = kcalloc(1, len, GFP_KERNEL);
> +	if (!data)
> +		return -ENOMEM;

trivia:

Not sure the kcalloc(1. ..) is useful.

It might be simpler using kzalloc, though given the memcpy_fromio
below a kcalloc/kzalloc seems dubious and kmalloc could be used.

>  	memcpy_fromio(data, priv->base, len);
>  	data[len - 1] = '\0';
>  



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

end of thread, other threads:[~2022-05-20  7:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-20  6:45 [PATCH v3] nvmem: brcm_nvram: check for allocation failure Dan Carpenter
2022-05-20  7:59 ` Joe Perches

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.