Re: [bug report] fprobe: Add exit_handler support

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Tue, 22 Mar 2022 09:46:20 +0300
Dan Carpenter <dan.carpenter@xxxxxxxxxx> wrote:

> Hello Masami Hiramatsu,
> 
> The patch 5b0ab78998e3: "fprobe: Add exit_handler support" from Mar
> 15, 2022, leads to the following Smatch static checker warning:
> 
> 	kernel/trace/fprobe.c:155 fprobe_init_rethook()
> 	warn: struct type mismatch 'rethook_node vs fprobe_rethook_node'
> 
> kernel/trace/fprobe.c
>     134 static int fprobe_init_rethook(struct fprobe *fp, int num)
>     135 {
>     136         int i, size;
>     137 
>     138         if (num < 0)
>     139                 return -EINVAL;
>     140 
>     141         if (!fp->exit_handler) {
>     142                 fp->rethook = NULL;
>     143                 return 0;
>     144         }
>     145 
>     146         /* Initialize rethook if needed */
>     147         size = num * num_possible_cpus() * 2;
>     148         if (size < 0)
>     149                 return -E2BIG;
>     150 
>     151         fp->rethook = rethook_alloc((void *)fp, fprobe_exit_handler);
>     152         for (i = 0; i < size; i++) {
>     153                 struct rethook_node *node;
>     154 
> --> 155                 node = kzalloc(sizeof(struct fprobe_rethook_node), GFP_KERNEL);
> 
> It's hard to tell if we're deliberately allocating a larger struct or
> whether it's accidental.

Good catch! This does not cause any error, but it should be;

struct fprobe_rethook_node *node;

node = kzalloc(sizeof(*node), GFP_KERNEL);
...
rethook_add_node(fp->rethook, &node->node);

Thank you!

> 
>     156                 if (!node) {
>     157                         rethook_free(fp->rethook);
>     158                         fp->rethook = NULL;
>     159                         return -ENOMEM;
>     160                 }
>     161                 rethook_add_node(fp->rethook, node);
>     162         }
>     163         return 0;
>     164 }
> 
> regards,
> dan carpenter


-- 
Masami Hiramatsu <mhiramat@xxxxxxxxxx>



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux