From: Takuya Yoshikawa Date: Thu, 27 May 2010 10:03:56 +0000 (+0900) Subject: vhost: fix the memory leak which will happen when memory_access_ok fails X-Git-Tag: v2.6.35-rc1~24^2~10 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a02c37891a9b2d7ce93f9d09455b4f67c4c23b95;p=platform%2Fkernel%2Flinux-3.10.git vhost: fix the memory leak which will happen when memory_access_ok fails We need to free newmem when vhost_set_memory() fails to complete. Signed-off-by: Takuya Yoshikawa Signed-off-by: Michael S. Tsirkin --- diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index e366202..da21ae9 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c @@ -337,8 +337,10 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) return -EFAULT; } - if (!memory_access_ok(d, newmem, vhost_has_feature(d, VHOST_F_LOG_ALL))) + if (!memory_access_ok(d, newmem, vhost_has_feature(d, VHOST_F_LOG_ALL))) { + kfree(newmem); return -EFAULT; + } oldmem = d->memory; rcu_assign_pointer(d->memory, newmem); synchronize_rcu();