misc: tegra-profiler: fix Coverity issue of NULL dereference
Deepak Nibade [Fri, 25 Jul 2014 07:05:45 +0000 (12:05 +0530)]
Pointer "pt_regs *regs" is first dereferenced and then checked for NULL
To fix this move NULL checking to beginning of function
Coverity id : 26686

Bug 1416640
Bug 1598009

Change-Id: I40e97e38e5a61a5d77ea68fa511e996f24385cfc
Signed-off-by: Deepak Nibade <dnibade@nvidia.com>
Reviewed-on: http://git-master/r/447532
(cherry picked from commit 4651be4faa111a0ff64a924889b69ec56ae19ace)
Reviewed-on: http://git-master/r/672015
GVS: Gerrit_Virtual_Submit
Reviewed-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Tested-by: Igor Nabirushkin <inabirushkin@nvidia.com>
Reviewed-by: Matthew Pedro <mapedro@nvidia.com>

drivers/misc/tegra-profiler/eh_unwind.c

index 70ffebe..52ca7be 100644 (file)
@@ -1021,6 +1021,9 @@ quadd_get_user_callchain_ut(struct pt_regs *regs,
        struct ex_region_info ri;
        struct stackframe frame;
 
+       if (!regs || !mm)
+               return 0;
+
 #ifdef CONFIG_ARM64
        if (!compat_user_mode(regs)) {
                pr_warn_once("user_mode 64: unsupported\n");
@@ -1033,9 +1036,6 @@ quadd_get_user_callchain_ut(struct pt_regs *regs,
 
        cc->unw_rc = QUADD_URC_FAILURE;
 
-       if (!regs || !mm)
-               return 0;
-
        if (nr_prev > 0) {
                ip = cc->curr_pc;
                sp = cc->curr_sp;