int nextcount;
        unsigned long *oops_page_used;
 
+       unsigned long oops_buf_busy;
        void *oops_buf;
 } oops_cxt;
 
        u32 *hdr;
        int ret;
 
+       if (test_and_set_bit(0, &cxt->oops_buf_busy))
+               return;
+
        /* Add mtdoops header to the buffer */
        hdr = cxt->oops_buf;
        hdr[0] = cxt->nextcount;
                                      record_size, &retlen, cxt->oops_buf);
                if (ret == -EOPNOTSUPP) {
                        printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n");
-                       return;
+                       goto out;
                }
        } else
                ret = mtd_write(mtd, cxt->nextpage * record_size,
        memset(cxt->oops_buf, 0xff, record_size);
 
        mtdoops_inc_counter(cxt);
+out:
+       clear_bit(0, &cxt->oops_buf_busy);
 }
 
 static void mtdoops_workfunc_write(struct work_struct *work)
        if (reason == KMSG_DUMP_OOPS && !dump_oops)
                return;
 
+       if (test_and_set_bit(0, &cxt->oops_buf_busy))
+               return;
        kmsg_dump_get_buffer(dumper, true, cxt->oops_buf + MTDOOPS_HEADER_SIZE,
                             record_size - MTDOOPS_HEADER_SIZE, NULL);
+       clear_bit(0, &cxt->oops_buf_busy);
 
        if (reason != KMSG_DUMP_OOPS) {
                /* Panics must be written immediately */
                return -ENOMEM;
        }
        memset(cxt->oops_buf, 0xff, record_size);
+       cxt->oops_buf_busy = 0;
 
        INIT_WORK(&cxt->work_erase, mtdoops_workfunc_erase);
        INIT_WORK(&cxt->work_write, mtdoops_workfunc_write);