spin_unlock_irqrestore(¤t->sighand->siglock, flags);
        }
 
-       return (bytes > 0);
+       /* if 'wr' returned 0 (impossible) we assume -EIO (safe) */
+       return bytes == 0 ? 0 : wr < 0 ? wr : -EIO;
 }
 
 static void autofs4_notify_daemon(struct autofs_sb_info *sbi,
        } pkt;
        struct file *pipe = NULL;
        size_t pktsz;
+       int ret;
 
        pr_debug("wait id = 0x%08lx, name = %.*s, type=%d\n",
                 (unsigned long) wq->wait_queue_token,
        mutex_unlock(&sbi->wq_mutex);
 
        if (autofs4_write(sbi, pipe, &pkt, pktsz))
+       switch (ret = autofs4_write(sbi, pipe, &pkt, pktsz)) {
+       case 0:
+               break;
+       case -ENOMEM:
+       case -ERESTARTSYS:
+               /* Just fail this one */
+               autofs4_wait_release(sbi, wq->wait_queue_token, ret);
+               break;
+       default:
                autofs4_catatonic_mode(sbi);
+               break;
+       }
        fput(pipe);
 }