Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1696529pxj; Wed, 19 May 2021 11:41:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwzG+RfyjBI5NBpVvTc9gRjrNDSXjxoqzLXtoDZBTuDJGxLo9JbsfHpo//Lt/SIQjg4AAA3 X-Received: by 2002:a17:906:9812:: with SMTP id lm18mr552563ejb.428.1621449711781; Wed, 19 May 2021 11:41:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621449711; cv=none; d=google.com; s=arc-20160816; b=NSDwqlJdlTewpS0lkp9nN0fYTeeHbrfJSIpskznCd7tH4x8DeaAEmhq/4U5yIfH7bV OzlQO2RfImN633MNGCja6l3dnyIuYHWfhlFwLG/gqcQl7hDF24ReBW909YfXS5wcfoIN 9jZlV6nPT3HXPmX/IadgxjXBnw91XJQXJUaIEv+YrBuEkX2BKkHqm0WR9xUowddHJNe2 8cgNxLRifko1j19IoyHLfBmSWW1TohG+aGj5hAJxXkEDOHMJYFReQlSKzYU9hOQTB6vA oVtdsgA+ocls/ZUsaBrU2mycDkpJMqtgv5YnaPHHldhMaH/oGSu+khrIrusATpqG6oSr uk+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=SbhE0iSK8kwkfF5k3gEa4k3XZSxzWdx+S3mqdnigAW8=; b=P7rXkcQY3RVF38Z1anyydruHWucPteZcAl7S6rLG3x3rfh9uhzzj3l+0QtMRXj0KtH gGs8L5EKCTgdVHykUmeC4FbfmkxvWZrUutOsXQdpbUFa38/GZrcZeqXroqephGVjfpeU qR5woSxVoo12GRWec0bVWg4gYIuWwE5FXjjBKKovj/etn4XA9Ta9kpwpYvx/lk1bJLvf 1Mr8O0/zkYVRnB8KGoq+O1QWACFRPJOLmscenw7c4qiGAdZr9dC+FdMKzeExGEuaEyE0 tWEShTNO1ylHq+4FFpnis+VJ5eD1ycgK0T1eMTxlaRaNK2xeeazczhdb+m0aKLQftVHx 5MIw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gb38si299730ejc.514.2021.05.19.11.41.25; Wed, 19 May 2021 11:41:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1352638AbhERVyo (ORCPT + 99 others); Tue, 18 May 2021 17:54:44 -0400 Received: from mail-wm1-f44.google.com ([209.85.128.44]:35633 "EHLO mail-wm1-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233561AbhERVym (ORCPT ); Tue, 18 May 2021 17:54:42 -0400 Received: by mail-wm1-f44.google.com with SMTP id z19-20020a7bc7d30000b029017521c1fb75so2332486wmk.0; Tue, 18 May 2021 14:53:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=SbhE0iSK8kwkfF5k3gEa4k3XZSxzWdx+S3mqdnigAW8=; b=eniDNL53vm0q9RuEC3o/4F+pG8zWA0HPzumJXlY4JikNmGf5rtqIA3fUj9OphpoDMl GZtQnMj9XUQVf4XbFz3QiBfShjcMbYJ7AEP679WG+9NsxrzbXGsGdBaB1jteA9qckIpw obwA8M2UlK13D9bfHS51SCwveGIoywxOV6RoWjvLeoG7xAG45QXphi4WAPfS23tFRjP9 WJ9F9GAqY5/ep6mB2uXxAdWMDWzSb71+GpwxW58AblD4YE7WergY8kZW0tuxpFKqiiO6 HEv8VlM0pUVwnRS1fgrkohk24W+jTQD65uCp3fAsOu2saylcwcGTMIFfjxxg8Z3VGztO Nv5g== X-Gm-Message-State: AOAM533rPKxQ/UaKfTLhfsVBQ/L89awGIiyO4GdqE+AB4q1ghdrnoXe5 of0cR4xxOel+7zngWCoRavY= X-Received: by 2002:a05:600c:4f4e:: with SMTP id m14mr7154705wmq.164.1621374801402; Tue, 18 May 2021 14:53:21 -0700 (PDT) Received: from liuwe-devbox-debian-v2 ([51.145.34.42]) by smtp.gmail.com with ESMTPSA id c12sm3284407wrr.90.2021.05.18.14.53.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 18 May 2021 14:53:21 -0700 (PDT) Date: Tue, 18 May 2021 21:53:19 +0000 From: Wei Liu To: Long Li Cc: Wei Liu , Christophe JAILLET , KY Srinivasan , Haiyang Zhang , Stephen Hemminger , Dexuan Cui , "gregkh@linuxfoundation.org" , "linux-hyperv@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "kernel-janitors@vger.kernel.org" Subject: Re: [PATCH 1/2] uio_hv_generic: Fix a memory leak in error handling paths Message-ID: <20210518215319.yshxwkvxaxsv77bv@liuwe-devbox-debian-v2> References: <4fdaff557deef6f0475d02ba7922ddbaa1ab08a6.1620544055.git.christophe.jaillet@wanadoo.fr> <20210511095227.ggrl3z6otjanwffz@liuwe-devbox-debian-v2> <20210518110122.7jbktl6olsl75vqz@liuwe-devbox-debian-v2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 18, 2021 at 09:50:17PM +0000, Long Li wrote: > > Subject: Re: [PATCH 1/2] uio_hv_generic: Fix a memory leak in error handling > > paths > > > > Cc Long Li. > > > > Long, Stephen suggested I check with you. Do you have any opinion? > > > > Wei. > > > > On Tue, May 11, 2021 at 09:52:27AM +0000, Wei Liu wrote: > > > On Sun, May 09, 2021 at 09:13:03AM +0200, Christophe JAILLET wrote: > > > > If 'vmbus_establish_gpadl()' fails, the (recv|send)_gpadl will not > > > > be updated and 'hv_uio_cleanup()' in the error handling path will > > > > not be able to free the corresponding buffer. > > > > > > > > In such a case, we need to free the buffer explicitly. > > > > > > > > Fixes: cdfa835c6e5e ("uio_hv_generic: defer opening vmbus until > > > > first use") > > > > Signed-off-by: Christophe JAILLET > > > > --- > > > > Before commit cdfa835c6e5e, the 'vfree' were done unconditionally in > > > > 'hv_uio_cleanup()'. > > > > So, another way for fixing the potential leak is to modify > > > > 'hv_uio_cleanup()' and revert to the previous behavior. > > > > > > > > > > I think this is cleaner. > > Christophe has mentioned that the patch is already picked up by Greg KH. > > I think both approaches are correct. We can go with this one. OK. That's fine. Wei.