summaryrefslogtreecommitdiffstats
path: root/drivers/staging/netlogic
diff options
context:
space:
mode:
authorLaura Garcia Liebana <nevola@gmail.com>2016-02-18 18:38:42 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2016-02-20 14:59:37 -0800
commit11b49d9bb63fab2f92223419a2492661e317e2ef (patch)
tree316c1608f524033173dfb3aa03ef4df5ce4df999 /drivers/staging/netlogic
parentbf8b2bb6d84031b7207154046f120052435fb196 (diff)
downloadlinux-11b49d9bb63fab2f92223419a2492661e317e2ef.tar.bz2
staging: netlogic: Return zero pointer after failed kmalloc
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/netlogic')
-rw-r--r--drivers/staging/netlogic/xlr_net.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/staging/netlogic/xlr_net.c b/drivers/staging/netlogic/xlr_net.c
index 98e74d777e09..00158471a7f6 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);