All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: netlogic: Return zero pointer after failed kmalloc
@ 2016-02-18 17:38 Laura Garcia Liebana
  2016-02-23 20:42 ` [Outreachy kernel] " Julia Lawall
  0 siblings, 1 reply; 6+ messages in thread
From: Laura Garcia Liebana @ 2016-02-18 17:38 UTC (permalink / raw)
  To: outreachy-kernel

Return a ZERO_SIZE_PTR in the xlr_config_spill function if the
kmalloc returns an invalid value. This change prevents a possible
segmentation fault as the invalid pointer is fed into PTR_ALIGN macro.

Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
---
 drivers/staging/netlogic/xlr_net.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index 98e74d7..0015847 100644
--- a/drivers/staging/netlogic/xlr_net.c
+++ b/drivers/staging/netlogic/xlr_net.c
@@ -437,8 +437,10 @@ static void *xlr_config_spill(struct xlr_net_priv *priv, int reg_start_0,
 	base = priv->base_addr;
 	spill_size = size;
 	spill = kmalloc(spill_size + SMP_CACHE_BYTES, GFP_ATOMIC);
-	if (!spill)
+	if (!spill) {
 		pr_err("Unable to allocate memory for spill area!\n");
+		return ZERO_SIZE_PTR;
+	}
 
 	spill = PTR_ALIGN(spill, SMP_CACHE_BYTES);
 	phys_addr = virt_to_phys(spill);
-- 
2.7.0



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

end of thread, other threads:[~2016-02-24 16:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-18 17:38 [PATCH] staging: netlogic: Return zero pointer after failed kmalloc Laura Garcia Liebana
2016-02-23 20:42 ` [Outreachy kernel] " Julia Lawall
2016-02-23 22:36   ` Laura Garcia
2016-02-24  9:23     ` Julia Lawall
2016-02-24 16:47       ` Laura Garcia
2016-02-24 16:55         ` Julia Lawall

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.