I found another helpful link and solved this problem.
This is the link:
kinetis bootloader and application startup
It was a Hardware ERRATA problem on the chip which causes the Clock Registers to not sync up when we are moving between Clock modes (FEI - FBE- PBE - PEE).
The application clock configuration from NXP had the fix to jump with syncing and resetting the clock register ( MCG->C1,C2,C4). But the bootloader didn't had the ERRATA fix.
So when the bootloader before jumping to application, it sets the clock configuration to FEI ( base clock mode).The app while doing its clock configuration is stuck in a while loop to get to PBE mode.
The fix was to add the ERRATA fix
#if 1
int dummy_var = 0;
for(int i = 0; i < 10000; i++)
{
dummy_var = MCG->S;
}
(void)dummy_var; // disable compiler warning
// This is required due to ERR007993
MCG->C4 &= ~MCG_C4_DMX32_MASK ;
#endif
in the clock_mode_switch() function in the case for :
"else if (expectedMode == kClockMode_FEI)"
in clock_config_K22F12.c
This Fixed the problem of application caught in the loop forever.