[PATCH] proc: fix alloc_cast.cocci warnings

From: kernel test robot
Date: Mon Jan 24 2022 - 22:15:42 EST


From: kernel test robot <lkp@xxxxxxxxx>

fs/proc/base.c:1767:14-18: WARNING: casting value returned by memory allocation function to (char *) is useless.

Remove casting the values returned by memory allocation functions
like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc.

Semantic patch information:
This makes an effort to find cases of casting of values returned by
kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc,
kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes
the casting as it is not required. The result in the patch case may
need some reformatting.

Generated by: scripts/coccinelle/api/alloc/alloc_cast.cocci

CC: Hao Lee <haolee.swjtu@xxxxxxxxx>
Reported-by: kernel test robot <lkp@xxxxxxxxx>
Signed-off-by: kernel test robot <lkp@xxxxxxxxx>
---

tree: https://github.com/0day-ci/linux/commits/UPDATE-20220123-215907/Hao-Lee/proc-use-kmalloc-instead-of-__get_free_page-to-alloc-path-buffer/20220123-181005
head: 98106e76de95ae9aefa914ec056448a5571155dc
commit: 98106e76de95ae9aefa914ec056448a5571155dc proc: alloc PATH_MAX bytes for /proc/${pid}/fd/ symlinks
:::::: branch date: 35 hours ago
:::::: commit date: 35 hours ago

base.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1764,7 +1764,7 @@ out:

static int do_proc_readlink(struct path *path, char __user *buffer, int buflen)
{
- char *tmp = (char *)kmalloc(PATH_MAX, GFP_KERNEL);
+ char *tmp = kmalloc(PATH_MAX, GFP_KERNEL);
char *pathname;
int len;