Skip to content

Commit

Permalink
[PATCH] uml: change memcpy to memmove
Browse files Browse the repository at this point in the history
Replace one memcpy() call with overlapping source and dest arguments with
one call to memmove(), to avoid data corruption.

Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
  • Loading branch information
Paolo 'Blaisorblade' Giarrusso authored and Linus Torvalds committed May 17, 2005
1 parent 0204881 commit 8f33228
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions arch/um/kernel/irq_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,9 +236,15 @@ static void free_irq_by_cb(int (*test)(struct irq_fd *, void *), void *arg)
(*prev)->fd, pollfds[i].fd);
goto out;
}
memcpy(&pollfds[i], &pollfds[i + 1],
(pollfds_num - i - 1) * sizeof(pollfds[0]));

pollfds_num--;

/* This moves the *whole* array after pollfds[i] (though
* it doesn't spot as such)! */

memmove(&pollfds[i], &pollfds[i + 1],
(pollfds_num - i) * sizeof(pollfds[0]));

if(last_irq_ptr == &old_fd->next)
last_irq_ptr = prev;
*prev = (*prev)->next;
Expand Down

0 comments on commit 8f33228

Please sign in to comment.