uid_t target_uid = amd_request_get_target_uid(req);
bundle *data = amd_request_get_bundle(req);
- caller_app_status = amd_app_status_find_by_pid(caller_pid);
- caller_appid = amd_app_status_get_appid(caller_app_status);
callee_appid = bundle_get_val(data, AUL_K_CALLEE_APPID);
- callee_app_status = amd_app_status_find_by_appid(callee_appid, target_uid);
- callee_pid = amd_app_status_get_pid(callee_app_status);
+ if (!callee_appid) {
+ _E("Failed to get callee appid");
+ return -1;
+ }
+
+ callee_app_status = amd_app_status_find_by_appid(callee_appid,
+ target_uid);
+ if (!callee_app_status) {
+ _E("Failed to find app status. appid(%s), uid(%u)",
+ callee_appid, target_uid);
+ return -1;
+ }
- __temporary_permission_drop_with_owner(caller_appid, callee_pid, target_uid);
+ caller_app_status = amd_app_status_find_by_pid(caller_pid);
+ if (!caller_app_status) {
+ _E("Failed to find app status. pid(%d)", caller_pid);
+ return -1;
+ }
+ caller_appid = amd_app_status_get_appid(caller_app_status);
+ callee_pid = amd_app_status_get_pid(callee_app_status);
+ __temporary_permission_drop_with_owner(caller_appid, callee_pid,
+ target_uid);
return 0;
}