[PATCH] slub: fix possible NULL pointer dereference - Kernel

This is a discussion on [PATCH] slub: fix possible NULL pointer dereference - Kernel ; This patch fix possible NULL pointer dereference if kzalloc failed. To be able to return proper error code the function return type is changed to ssize_t (according to callees and sysfs definitions). Signed-off-by: Cyrill Gorcunov --- Index: linux-2.6.git/mm/slub.c ================================================== ================= ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: [PATCH] slub: fix possible NULL pointer dereference

  1. [PATCH] slub: fix possible NULL pointer dereference

    This patch fix possible NULL pointer dereference if kzalloc
    failed. To be able to return proper error code the function
    return type is changed to ssize_t (according to callees and
    sysfs definitions).

    Signed-off-by: Cyrill Gorcunov
    ---

    Index: linux-2.6.git/mm/slub.c
    ================================================== =================
    --- linux-2.6.git.orig/mm/slub.c 2008-03-02 22:53:27.000000000 +0300
    +++ linux-2.6.git/mm/slub.c 2008-03-02 23:02:27.000000000 +0300
    @@ -3591,8 +3591,8 @@ enum slab_stat_type {
    #define SO_CPU (1 << SL_CPU)
    #define SO_OBJECTS (1 << SL_OBJECTS)

    -static unsigned long slab_objects(struct kmem_cache *s,
    - char *buf, unsigned long flags)
    +static ssize_t slab_objects(struct kmem_cache *s,
    + char *buf, unsigned long flags)
    {
    unsigned long total = 0;
    int cpu;
    @@ -3602,6 +3602,8 @@ static unsigned long slab_objects(struct
    unsigned long *per_cpu;

    nodes = kzalloc(2 * sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
    + if (!nodes)
    + return -ENOMEM;
    per_cpu = nodes + nr_node_ids;

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

  2. Re: [PATCH] slub: fix possible NULL pointer dereference

    On Sun, Mar 2, 2008 at 10:28 PM, Cyrill Gorcunov wrote:
    > This patch fix possible NULL pointer dereference if kzalloc
    > failed. To be able to return proper error code the function
    > return type is changed to ssize_t (according to callees and
    > sysfs definitions).
    >
    > Signed-off-by: Cyrill Gorcunov


    Looks good to me.

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

  3. Re: [PATCH] slub: fix possible NULL pointer dereference

    Thanks for review, Pekka, and sorry for not cc'ed you on initial
    submittion (just missed
    --
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread