From patchwork Thu May 27 10:03:56 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takuya Yoshikawa X-Patchwork-Id: 102598 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4RA3gc4031503 for ; Thu, 27 May 2010 10:03:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932527Ab0E0KDd (ORCPT ); Thu, 27 May 2010 06:03:33 -0400 Received: from serv2.oss.ntt.co.jp ([222.151.198.100]:48090 "EHLO serv2.oss.ntt.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757884Ab0E0KDd (ORCPT ); Thu, 27 May 2010 06:03:33 -0400 Received: from serv2.oss.ntt.co.jp (localhost [127.0.0.1]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 14EF9248317; Thu, 27 May 2010 19:03:32 +0900 (JST) Received: from serv1.oss.ntt.co.jp (serv1.oss.ntt.co.jp [172.19.0.2]) by serv2.oss.ntt.co.jp (Postfix) with ESMTP id 03AA4248315; Thu, 27 May 2010 19:03:32 +0900 (JST) Received: from yshtky3.kern.oss.ntt.co.jp (unknown [172.17.1.110]) by serv1.oss.ntt.co.jp (Postfix) with SMTP id E120D11C11D; Thu, 27 May 2010 19:03:31 +0900 (JST) Date: Thu, 27 May 2010 19:03:56 +0900 From: Takuya Yoshikawa To: mst@redhat.com Cc: kvm@vger.kernel.org, virtualization@lists.osdl.org, netdev@vger.kernel.org Subject: [PATCH 3/3] vhost: fix the memory leak which will happen when memory_access_ok fails Message-Id: <20100527190356.cbf2aac7.yoshikawa.takuya@oss.ntt.co.jp> In-Reply-To: <20100527185803.0c0213a1.yoshikawa.takuya@oss.ntt.co.jp> References: <20100527185803.0c0213a1.yoshikawa.takuya@oss.ntt.co.jp> X-Mailer: Sylpheed 3.0.2 (GTK+ 2.20.1; i486-pc-linux-gnu) Mime-Version: 1.0 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 10:03:42 +0000 (UTC) diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 9633a3c..1241a22 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();