diff options
-rw-r--r-- | drivers/video/console/vgacon.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/video/console/vgacon.c b/drivers/video/console/vgacon.c index 6df29a62d720..3556268fe0a0 100644 --- a/drivers/video/console/vgacon.c +++ b/drivers/video/console/vgacon.c | |||
@@ -292,23 +292,26 @@ static int vgacon_scrolldelta(struct vc_data *c, int lines) | |||
292 | d = (void *) c->vc_origin; | 292 | d = (void *) c->vc_origin; |
293 | s = (void *) c->vc_screenbuf; | 293 | s = (void *) c->vc_screenbuf; |
294 | 294 | ||
295 | while (count--) { | 295 | if (count) { |
296 | scr_memcpyw(d, vgacon_scrollback + soff, c->vc_size_row); | 296 | int copysize; |
297 | d += c->vc_size_row; | 297 | count *= c->vc_size_row; |
298 | soff += c->vc_size_row; | 298 | /* how much memory to end of buffer left? */ |
299 | 299 | copysize = min(count, vgacon_scrollback_size - soff); | |
300 | if (soff >= vgacon_scrollback_size) | 300 | scr_memcpyw(d, vgacon_scrollback + soff, copysize); |
301 | soff = 0; | 301 | d += copysize; |
302 | count -= copysize; | ||
303 | |||
304 | if (count) { | ||
305 | scr_memcpyw(d, vgacon_scrollback, count); | ||
306 | d += count; | ||
307 | } | ||
302 | } | 308 | } |
303 | 309 | ||
304 | if (diff == c->vc_rows) { | 310 | if (diff == c->vc_rows) { |
305 | vgacon_cursor(c, CM_MOVE); | 311 | vgacon_cursor(c, CM_MOVE); |
306 | } else { | 312 | } else { |
307 | while (diff--) { | 313 | if (diff) |
308 | scr_memcpyw(d, s, c->vc_size_row); | 314 | scr_memcpyw(d, s, diff * c->vc_size_row); |
309 | d += c->vc_size_row; | ||
310 | s += c->vc_size_row; | ||
311 | } | ||
312 | } | 315 | } |
313 | 316 | ||
314 | return 1; | 317 | return 1; |