fs: pstore: Replaced calls to kmalloc and memcpy with kmemdup
PATCH 1/1 fs: pstore: Replaced calls to kmalloc and memcpy with kmemdup
Replaced calls to kmalloc and memcpy with a single call to kmemdup. This patch was found using coccicheck.
Signed-off-by Alexandru Gheorghiu <[email protected]>
--- fs/pstore/ram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
fs/pstore/ram.c +1 -2
@@ -156,10 +156,9 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec =0 ; size =persistent_ram_old_size (prz); - *buf =kmalloc (size,GFP_KERNEL ); + *buf =kmemdup (persistent_ram_old (prz), size,GFP_KERNEL );if (*buf ==NULL )return -ENOMEM ; -memcpy (*buf,persistent_ram_old (prz), size);return size; }
Signature · 1 line
1.7.9.5
Quoted 14 lines · Alexandru Gheorghiu
Replaced calls to kmalloc and memcpy with a single call to kmemdup. This patch was found using coccicheck.
Signed-off-by Alexandru Gheorghiu <[email protected]>--- fs/pstore/ram.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)fs/pstore/ram.c +0
-0@@ -156,10 +156,9 @@ static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, time->tv_nsec =0 ;
fs/pstore/ram.c static ssize_t ramoops_pstore_read(u64 *id, enum pstore_type_id *type, · line 164
Quoted 10 lines
fs/pstore/ram.c +1
-2size =persistent_ram_old_size (prz); - *buf =kmalloc (size,GFP_KERNEL ); + *buf =kmemdup (persistent_ram_old (prz), size,GFP_KERNEL );if (*buf ==NULL )return -ENOMEM ; -memcpy (*buf,persistent_ram_old (prz), size);return size; }
Looks fine to me. Thanks!
Acked-by Kees Cook <[email protected]>
-Kees
Signature · 2 lines
Kees Cook Chrome OS Security
Anton Vorontsov
AppliedQuoted 6 lines · Kees Cook
Quoted 4 lines · Alexandru Gheorghiu
Replaced calls to kmalloc and memcpy with a single call to kmemdup. This patch was found using coccicheck.
Signed-off-by Alexandru Gheorghiu <[email protected]>
[...]
Quoted 3 lines
Looks fine to me. Thanks!
Acked-by Kees Cook <[email protected]>
Applied to linux-pstore.git, thanks a lot!
Anton