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-Url: http://git.osdn.net/view?a=commitdiff_plain;h=a02c37891a9b2d7ce93f9d09455b4f67c4c23b95;p=sagit-ice-cold%2Fkernel_xiaomi_msm8998.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 e36620272715..da21ae951826 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();