diff mbox series

[04/19] EDAC, mc: Do not BUG_ON() in edac_mc_alloc()

Message ID 20191010202418.25098-5-rrichter@marvell.com
State Superseded
Headers show
Series EDAC: Rework edac_mc and ghes drivers | expand

Commit Message

Robert Richter Oct. 10, 2019, 8:25 p.m. UTC
No need to crash the system in case edac_mc_alloc() is called with
invalid arguments, just warn and return. This would cause a checkpatch
warning when touching the code later, so just fix it.

Signed-off-by: Robert Richter <rrichter@marvell.com>

---
 drivers/edac/edac_mc.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

-- 
2.20.1

Comments

Mauro Carvalho Chehab Oct. 11, 2019, 10:15 a.m. UTC | #1
Em Thu, 10 Oct 2019 20:25:12 +0000
Robert Richter <rrichter@marvell.com> escreveu:

> No need to crash the system in case edac_mc_alloc() is called with

> invalid arguments, just warn and return. This would cause a checkpatch

> warning when touching the code later, so just fix it.

> 

> Signed-off-by: Robert Richter <rrichter@marvell.com>


Reviewed-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>


> ---

>  drivers/edac/edac_mc.c | 4 +++-

>  1 file changed, 3 insertions(+), 1 deletion(-)

> 

> diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c

> index c5240bb4c6c0..f2cbca77bc50 100644

> --- a/drivers/edac/edac_mc.c

> +++ b/drivers/edac/edac_mc.c

> @@ -323,7 +323,9 @@ struct mem_ctl_info *edac_mc_alloc(unsigned int mc_num,

>  	int i, j, row, chn, n, len;

>  	bool per_rank = false;

>  

> -	BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0);

> +	if (WARN_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0))

> +		return NULL;

> +

>  	/*

>  	 * Calculate the total amount of dimms and csrows/cschannels while

>  	 * in the old API emulation mode




Thanks,
Mauro
diff mbox series

Patch

diff --git a/drivers/edac/edac_mc.c b/drivers/edac/edac_mc.c
index c5240bb4c6c0..f2cbca77bc50 100644
--- a/drivers/edac/edac_mc.c
+++ b/drivers/edac/edac_mc.c
@@ -323,7 +323,9 @@  struct mem_ctl_info *edac_mc_alloc(unsigned int mc_num,
 	int i, j, row, chn, n, len;
 	bool per_rank = false;
 
-	BUG_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0);
+	if (WARN_ON(n_layers > EDAC_MAX_LAYERS || n_layers == 0))
+		return NULL;
+
 	/*
 	 * Calculate the total amount of dimms and csrows/cschannels while
 	 * in the old API emulation mode