Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933092AbdHVOnU (ORCPT ); Tue, 22 Aug 2017 10:43:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4540 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932894AbdHVOnG (ORCPT ); Tue, 22 Aug 2017 10:43:06 -0400 From: nixiaoming To: , , , , , CC: , , , Subject: [PATCH] fix memory leak on kvm_vm_ioctl_create_spapr_tce Date: Tue, 22 Aug 2017 22:28:23 +0800 Message-ID: <20170822142823.69425-1-nixiaoming@huawei.com> X-Mailer: git-send-email 2.11.0.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.187.180] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A0B0205.599C42F7.01BB,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2014-11-16 11:51:01, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 88cef59ce7a695c7db8a15fd284cc1ac Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 784 Lines: 27 miss kfree(stt) when anon_inode_getfd return fail so add check anon_inode_getfd return val, and kfree stt Signed-off-by: nixiaoming --- arch/powerpc/kvm/book3s_64_vio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/kvm/book3s_64_vio.c b/arch/powerpc/kvm/book3s_64_vio.c index a160c14..a0b4459 100644 --- a/arch/powerpc/kvm/book3s_64_vio.c +++ b/arch/powerpc/kvm/book3s_64_vio.c @@ -341,8 +341,11 @@ long kvm_vm_ioctl_create_spapr_tce(struct kvm *kvm, mutex_unlock(&kvm->lock); - return anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops, + ret = anon_inode_getfd("kvm-spapr-tce", &kvm_spapr_tce_fops, stt, O_RDWR | O_CLOEXEC); + if (ret < 0) + goto fail; + return ret; fail: if (stt) { -- 2.11.0.1