Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Register
  • Sign in
  • L linux
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • Kirill Smelkov
  • linux
  • Repository
You need to sign in or sign up before continuing.
  • linux
  • kernel
  • trace
  • fprobe.c
Find file BlameHistoryPermalink
  • Masami Hiramatsu (Google)'s avatar
    tracing: fprobe: Initialize ret valiable to fix smatch error · 6049674b
    Masami Hiramatsu (Google) authored Apr 09, 2023
    The commit 39d95420 ("fprobe: Skip exit_handler if entry_handler returns
    !0") introduced a hidden dependency of 'ret' local variable in the
    fprobe_handler(), Smatch warns the `ret` can be accessed without
    initialization.
    
    	kernel/trace/fprobe.c:59 fprobe_handler()
    	error: uninitialized symbol 'ret'.
    
    kernel/trace/fprobe.c
        49                 fpr->entry_ip = ip;
        50                 if (fp->entry_data_size)
        51                         entry_data = fpr->data;
        52         }
        53
        54         if (fp->entry_handler)
        55                 ret = fp->entry_handler(fp, ip, ftrace_get_regs(fregs), entry_data);
    
    ret is only initialized if there is an ->entry_handler
    
        56
        57         /* If entry_handler returns !0, nmissed is not counted. */
        58         if (rh) {
    
    rh is only true if there is an ->exit_handler.  Presumably if you have
    and ->exit_handler that means you also have a ->entry_handler but Smatch
    is not smart enough to figure it out.
    
    --> 59                 if (ret)
                               ^^^
    Warning here.
    
        60                         rethook_recycle(rh);
        61                 else
        62                         rethook_hook(rh, ftrace_get_regs(fregs), true);
        63         }
        64 out:
        65         ftrace_test_recursion_unlock(bit);
        66 }
    
    Link: https://lore.kernel.org/all/168100731160.79534.374827110083836722.stgit@devnote2/
    
    
    
    Reported-by: default avatarDan Carpenter <error27@gmail.com>
    Link: https://lore.kernel.org/all/85429a5c-a4b9-499e-b6c0-cbd313291c49@kili.mountain
    Fixes: 39d95420
    
     ("fprobe: Skip exit_handler if entry_handler returns !0")
    Acked-by: default avatarDan Carpenter <dan.carpenter@linaro.org>
    Signed-off-by: default avatarMasami Hiramatsu (Google) <mhiramat@kernel.org>
    6049674b
GitLab Nexedi Edition | About GitLab | About Nexedi | 沪ICP备2021021310号-2 | 沪ICP备2021021310号-7