Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3542008pxj; Mon, 24 May 2021 09:01:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+3d5cIw05ktXmjA1qeqYf26J0W2x1ZRsRRZjmIhTKDwx+oWMp0YAdh0jFkbLn9lIm1Qhc X-Received: by 2002:a5d:4b10:: with SMTP id v16mr22048718wrq.259.1621872086691; Mon, 24 May 2021 09:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621872086; cv=none; d=google.com; s=arc-20160816; b=eAEWlf8cgcL9SxctIQPV3i4jUvtDsBK+3iYt7af+OWwNCE8HOKHjmSKOyczdbkachX DC+sNUSJMFrMaH2tzqcOxtSbfCn6NIbXyHwkfuVMkOwYE9VGW55qs2Z4CkSEcJ1FpWjv oc0n7aaF+rb5jHY2VxfVS2nOeEu/NiBAXnX8UV9Mmu1adqmD8yDI9ulHU4mGzusnAk8I 9SLJmqArzTv3jj+++ySTpCzvfb8NcfW0sbQtWXwyC6EqJHNcZ4E2KHocywea3JzNBqwv t6SqA6imyJ0VswdqGY3giq0kwmb2QlhoTn5aFSaZc+lTtqIhXwkOGubeGadh/cQyT2cN DSEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=CC85L3gfxgeAkeb8mL6XIT6rHfTCXD6f2lw32NdkXDU=; b=kiuxh/9So9FtRdMLByXBuNN+OFwsTr12FIV5PML6lhKq3yrt7PH4Hclr8zaml5c7Db N2ABABXrBXTjto/k0hjZxC/SYeMZWMNndhXdWbHg74KakVkmG+ALO8UHHECTYPSC+9sD jRBM4J8uC9p8TVkd7i7s8L4I6PLyCE4AeOT73s1fJ4tXeEwPlZ0T6BSwpQu56ynq17pl 1/Uhw91kMA10r2H/alVV0DIp0CMQexsxZqOSD1DFfyYpccQNPe5F9qR58cvQZvd4JQ23 k6Ftcqi/+gBYz2b4hiO+hGupbRZYKZCmx3yZx+iXvwCnldKnJjW0anMorDBT+jqMdqCW Jfyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wu7Xdl5p; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g18si12008279edb.157.2021.05.24.09.01.02; Mon, 24 May 2021 09:01:26 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Wu7Xdl5p; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235516AbhEXP7h (ORCPT + 99 others); Mon, 24 May 2021 11:59:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:40462 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235212AbhEXPzC (ORCPT ); Mon, 24 May 2021 11:55:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EFE826142D; Mon, 24 May 2021 15:40:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621870838; bh=0/p0tc9WrNj0jr3ZyF9G/zdESfFGAEkfgCe3qd7ps5w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wu7Xdl5pNvze3MNDFWUDfrGAp++6thau2mW7BrLXf4Abx2toJ8p9w+lvnGhMEEW25 ZwBqw383sKPdZPB4VTXqXs0F+Qu9tjBOy8GwgEZw03A9jeNuq2RMG/wDymyAzahw8w k1j0Dw2yRDS5ghR9bdKzNmzsrFecJwqTdt2+mzWU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET Subject: [PATCH 5.10 050/104] uio_hv_generic: Fix a memory leak in error handling paths Date: Mon, 24 May 2021 17:25:45 +0200 Message-Id: <20210524152334.503712061@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210524152332.844251980@linuxfoundation.org> References: <20210524152332.844251980@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe JAILLET commit 3ee098f96b8b6c1a98f7f97915f8873164e6af9d upstream. 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") Cc: stable Signed-off-by: Christophe JAILLET Link: https://lore.kernel.org/r/4fdaff557deef6f0475d02ba7922ddbaa1ab08a6.1620544055.git.christophe.jaillet@wanadoo.fr Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio_hv_generic.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) --- a/drivers/uio/uio_hv_generic.c +++ b/drivers/uio/uio_hv_generic.c @@ -296,8 +296,10 @@ hv_uio_probe(struct hv_device *dev, ret = vmbus_establish_gpadl(channel, pdata->recv_buf, RECV_BUFFER_SIZE, &pdata->recv_gpadl); - if (ret) + if (ret) { + vfree(pdata->recv_buf); goto fail_close; + } /* put Global Physical Address Label in name */ snprintf(pdata->recv_name, sizeof(pdata->recv_name), @@ -316,8 +318,10 @@ hv_uio_probe(struct hv_device *dev, ret = vmbus_establish_gpadl(channel, pdata->send_buf, SEND_BUFFER_SIZE, &pdata->send_gpadl); - if (ret) + if (ret) { + vfree(pdata->send_buf); goto fail_close; + } snprintf(pdata->send_name, sizeof(pdata->send_name), "send:%u", pdata->send_gpadl);