int index)
 {
        struct omap3_idle_statedata *cx = &omap3_idle_data[index];
+       int error;
 
        if (omap_irq_pending() || need_resched())
                goto return_sleep_time;
         * Call idle CPU PM enter notifier chain so that
         * VFP context is saved.
         */
-       if (cx->mpu_state == PWRDM_POWER_OFF)
-               cpu_pm_enter();
+       if (cx->mpu_state == PWRDM_POWER_OFF) {
+               error = cpu_pm_enter();
+               if (error)
+                       goto out_clkdm_set;
+       }
 
        /* Execute ARM wfi */
        omap_sram_idle();
            pwrdm_read_prev_pwrst(mpu_pd) == PWRDM_POWER_OFF)
                cpu_pm_exit();
 
+out_clkdm_set:
        /* Re-allow idle for C1 */
        if (cx->flags & OMAP_CPUIDLE_CX_NO_CLKDM_IDLE)
                clkdm_allow_idle(mpu_pd->pwrdm_clkdms[0]);
 
 {
        struct idle_statedata *cx = state_ptr + index;
        u32 mpuss_can_lose_context = 0;
+       int error;
 
        /*
         * CPU0 has to wait and stay ON until CPU1 is OFF state.
         * Call idle CPU PM enter notifier chain so that
         * VFP and per CPU interrupt context is saved.
         */
-       cpu_pm_enter();
+       error = cpu_pm_enter();
+       if (error)
+               goto cpu_pm_out;
 
        if (dev->cpu == 0) {
                pwrdm_set_logic_retst(mpu_pd, cx->mpu_logic_state);
                 * Call idle CPU cluster PM enter notifier chain
                 * to save GIC and wakeupgen context.
                 */
-               if (mpuss_can_lose_context)
-                       cpu_cluster_pm_enter();
+               if (mpuss_can_lose_context) {
+                       error = cpu_cluster_pm_enter();
+                       if (error)
+                               goto cpu_cluster_pm_out;
+               }
        }
 
        omap4_enter_lowpower(dev->cpu, cx->cpu_state);
        cpu_done[dev->cpu] = true;
 
+cpu_cluster_pm_out:
        /* Wakeup CPU1 only if it is not offlined */
        if (dev->cpu == 0 && cpumask_test_cpu(1, cpu_online_mask)) {
 
                }
        }
 
-       /*
-        * Call idle CPU PM exit notifier chain to restore
-        * VFP and per CPU IRQ context.
-        */
-       cpu_pm_exit();
-
        /*
         * Call idle CPU cluster PM exit notifier chain
         * to restore GIC and wakeupgen context.
        if (dev->cpu == 0 && mpuss_can_lose_context)
                cpu_cluster_pm_exit();
 
+       /*
+        * Call idle CPU PM exit notifier chain to restore
+        * VFP and per CPU IRQ context.
+        */
+       cpu_pm_exit();
+
+cpu_pm_out:
        tick_broadcast_exit();
 
 fail:
 
        int per_next_state = PWRDM_POWER_ON;
        int core_next_state = PWRDM_POWER_ON;
        u32 sdrc_pwr = 0;
+       int error;
 
        mpu_next_state = pwrdm_read_next_pwrst(mpu_pwrdm);
        switch (mpu_next_state) {
        pwrdm_pre_transition(NULL);
 
        /* PER */
-       if (per_next_state == PWRDM_POWER_OFF)
-               cpu_cluster_pm_enter();
+       if (per_next_state == PWRDM_POWER_OFF) {
+               error = cpu_cluster_pm_enter();
+               if (error)
+                       return;
+       }
 
        /* CORE */
        if (core_next_state < PWRDM_POWER_ON) {