Re: [PATCH] Fix to return wrong pointer in slob




On Mon, 2008-05-19 at 22:12 +0900, MinChan Kim wrote:
Although slob_alloc return NULL, __kmalloc_node returns NULL + align.
Because align always can be changed, it is very hard for debugging
problem of no page if it don't return NULL.

We have to return NULL in case of no page.

Signed-off-by: MinChan Kim <minchan.kim@xxxxxxxxx>
---
mm/slob.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/mm/slob.c b/mm/slob.c
index 6038cba..258d76d 100644
--- a/mm/slob.c
+++ b/mm/slob.c
@@ -469,9 +469,12 @@ void *__kmalloc_node(size_t size, gfp_t gfp, int node)
return ZERO_SIZE_PTR;

m = slob_alloc(size + align, gfp, align, node);
- if (m)
- *m = size;
- return (void *)m + align;
+ if (!m)
+ return NULL;
+ else {
+ *m = size;
+ return (void *)m + align;
+ }

This looks good, but I would remove the 'else {' and '}' here. It's nice
to have the 'normal path' minimally indented.

Otherwise,

Acked-by: Matt Mackall <mpm@xxxxxxxxxxx>

[cc:ed to Pekka, who manages the allocator tree]

} else {
void *ret;

--
Mathematics is the supreme nostalgia of our time.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



Relevant Pages

  • Re: [patch] Make slab allocator work with SLAB_MUST_HWCACHE_ALIGN
    ... Which debugging of, it's equivalent to ... There was a patch, but it's quite intrusive ... Align everything always to L1_CACHE_BYTES. ... minimal numa patch wouldn't contain any core changes either. ...
    (Linux-Kernel)
  • Re: [PATCH] Fix to return wrong pointer in slob
    ... Because align always can be changed, it is very hard for debugging ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • [PATCH] Fix to return wrong pointer in slob
    ... Because align always can be changed, it is very hard for debugging ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)
  • Re: [PATCH] slob: handle SLAB_PANIC flag
    ... if (c->align < align) ... Mathematics is the supreme nostalgia of our time. ... More majordomo info at http://vger.kernel.org/majordomo-info.html ... Please read the FAQ at http://www.tux.org/lkml/ ...
    (Linux-Kernel)