devres: restore zeroing behavior of devres_alloc()
authorKevin Hilman <khilman@linaro.org>
Mon, 19 May 2014 13:14:35 +0000 (14:14 +0100)
committerMark Brown <broonie@linaro.org>
Mon, 19 May 2014 17:01:19 +0000 (18:01 +0100)
commit 64c862a8 (devres: add kernel standard devm_k.alloc functions) changed
the default behavior of alloc_dr() to no longer zero the allocated memory.  However,
only the devm.k.alloc() function were modified to pass in __GFP_ZERO which leaves
any users of devres_alloc() or __devres_alloc() with potentially wrong assumptions
about memory being zero'd upon allocation.

To fix, add __GFP_ZERO to devres_alloc() calls to preserve previous
behavior of zero'ing memory upon allocation.

Signed-off-by: Kevin Hilman <khilman@linaro.org>
Cc: Tejun Heo <tj@kernel.org>
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6fffcfa7c0fc438d3667b4eb2074d94f69c12c7b)
Signed-off-by: Ryan Harkin <ryan.harkin@linaro.org>
Signed-off-by: Mark Brown <broonie@linaro.org>
drivers/base/devres.c

index 37e67a26e3880bab082841994ea3550fbf7b4278..545c4de412c3e0ba5a2680d9143e059a9c475dbd 100644 (file)
@@ -111,7 +111,7 @@ void * __devres_alloc(dr_release_t release, size_t size, gfp_t gfp,
 {
        struct devres *dr;
 
-       dr = alloc_dr(release, size, gfp);
+       dr = alloc_dr(release, size, gfp | __GFP_ZERO);
        if (unlikely(!dr))
                return NULL;
        set_node_dbginfo(&dr->node, name, size);
@@ -136,7 +136,7 @@ void * devres_alloc(dr_release_t release, size_t size, gfp_t gfp)
 {
        struct devres *dr;
 
-       dr = alloc_dr(release, size, gfp);
+       dr = alloc_dr(release, size, gfp | __GFP_ZERO);
        if (unlikely(!dr))
                return NULL;
        return dr->data;