]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/char/mem.c
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/livepatchin...
[linux.git] / drivers / char / mem.c
index b08dc50f9f26026730c5eb12ee8e4be47012c2f8..9eb564c002f66e221646c5225e69ff71b38f913e 100644 (file)
@@ -97,6 +97,13 @@ void __weak unxlate_dev_mem_ptr(phys_addr_t phys, void *addr)
 }
 #endif
 
+static inline bool should_stop_iteration(void)
+{
+       if (need_resched())
+               cond_resched();
+       return fatal_signal_pending(current);
+}
+
 /*
  * This funcion reads the *physical* memory. The f_pos points directly to the
  * memory location.
@@ -175,6 +182,8 @@ static ssize_t read_mem(struct file *file, char __user *buf,
                p += sz;
                count -= sz;
                read += sz;
+               if (should_stop_iteration())
+                       break;
        }
        kfree(bounce);
 
@@ -251,6 +260,8 @@ static ssize_t write_mem(struct file *file, const char __user *buf,
                p += sz;
                count -= sz;
                written += sz;
+               if (should_stop_iteration())
+                       break;
        }
 
        *ppos += written;
@@ -468,6 +479,10 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
                        read += sz;
                        low_count -= sz;
                        count -= sz;
+                       if (should_stop_iteration()) {
+                               count = 0;
+                               break;
+                       }
                }
        }
 
@@ -492,6 +507,8 @@ static ssize_t read_kmem(struct file *file, char __user *buf,
                        buf += sz;
                        read += sz;
                        p += sz;
+                       if (should_stop_iteration())
+                               break;
                }
                free_page((unsigned long)kbuf);
        }
@@ -544,6 +561,8 @@ static ssize_t do_write_kmem(unsigned long p, const char __user *buf,
                p += sz;
                count -= sz;
                written += sz;
+               if (should_stop_iteration())
+                       break;
        }
 
        *ppos += written;
@@ -595,6 +614,8 @@ static ssize_t write_kmem(struct file *file, const char __user *buf,
                        buf += sz;
                        virtr += sz;
                        p += sz;
+                       if (should_stop_iteration())
+                               break;
                }
                free_page((unsigned long)kbuf);
        }