Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4535556imm; Mon, 17 Sep 2018 16:03:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbIqQbANwzDbSiTqX39C8JHG2y75DUqSXmQQ9saE/H13/agBRWSolc9QDu6mcZkw3Hcz6IZ X-Received: by 2002:a63:7d7:: with SMTP id 206-v6mr25870280pgh.17.1537225413121; Mon, 17 Sep 2018 16:03:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537225413; cv=none; d=google.com; s=arc-20160816; b=x6T2VivjIuxkLVJbHbKbeDUVM7L/cLPy6DOUNp6lz0BrB6nfzfIpTPvJF3pGM8qYrP TDdhQwkEHPIrkuSG1uSBs17ckFEeUth5Z7J1zzdxirM9AcE24wGYNPC6LVh4+ZEJpkpR XcvMLGHbbp1z9T7L6Cjy25pj8xtPnsskYekwHhAaK6Odzbhfcrox3uJkzCSHN+KYdowC R/A4wmrvf+PbBtaUUna8P9RTqRtQdaBB7DCuK2zBMsaf6OrWMp5K2wgC4onhgqL4NUsn LHqgYFs0oy+qLPri83uucnRq63Ow51Cvj3al5nvtE6+liXN+wUFyDw4hAhKaivNp4qOy 2jTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=XA00x8N0Q9uRr+nJYFXU1dO9uEoEh/hUsMnW5zEKIzQ=; b=ub/cLdDTzRBO7cp4kEc0B3mjGbz3DrlIwI3VKCi4nnqOvuzWfLg4/djtTU+NYBKCHX 4aQrQyF+J8zoAxB9IamfF9Ga3DgpE/bbcMY5L7zKNFGQsL+y/q5MVlRQ2Se08S4Yduf7 B4vvB79LGlay+/1YNuaE7bcnsm2/E3Q+3/Q50TGL27Ayn1lW1f6hG09VGa6hVQ9bZVbe uOZOIQQLXGxFGGqPf5Vb9eXmea8BakURP+q19MD/u7n1T5NHcyE6GHROSCSbc9e/qp/0 G3XiSOOm2R3lqJP2N6InYGNwSsiT+Bwb7XQyMrN6pdquY62dNj2yo4ItidWhdrfP0tnk Ibuw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4-v6si16894804pgk.630.2018.09.17.16.03.17; Mon, 17 Sep 2018 16:03:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730276AbeIREbQ (ORCPT + 99 others); Tue, 18 Sep 2018 00:31:16 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:48332 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727088AbeIREbP (ORCPT ); Tue, 18 Sep 2018 00:31:15 -0400 Received: from localhost (li1825-44.members.linode.com [172.104.248.44]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id EECADC03; Mon, 17 Sep 2018 23:01:46 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kelley , Dan Carpenter , "K. Y. Srinivasan" , Sasha Levin Subject: [PATCH 4.14 041/126] Drivers: hv: vmbus: Cleanup synic memory free path Date: Tue, 18 Sep 2018 00:41:29 +0200 Message-Id: <20180917211707.398629040@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180917211703.481236999@linuxfoundation.org> References: <20180917211703.481236999@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael Kelley [ Upstream commit 572086325ce9a9e348b8748e830653f3959e88b6 ] clk_evt memory is not being freed when the synic is shutdown or when there is an allocation error. Add the appropriate kfree() call, along with a comment to clarify how the memory gets freed after an allocation error. Make the free path consistent by removing checks for NULL since kfree() and free_page() already do the check. Signed-off-by: Michael Kelley Reported-by: Dan Carpenter Signed-off-by: K. Y. Srinivasan Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/hv/hv.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c @@ -196,6 +196,10 @@ int hv_synic_alloc(void) return 0; err: + /* + * Any memory allocations that succeeded will be freed when + * the caller cleans up by calling hv_synic_free() + */ return -ENOMEM; } @@ -208,12 +212,10 @@ void hv_synic_free(void) struct hv_per_cpu_context *hv_cpu = per_cpu_ptr(hv_context.cpu_context, cpu); - if (hv_cpu->synic_event_page) - free_page((unsigned long)hv_cpu->synic_event_page); - if (hv_cpu->synic_message_page) - free_page((unsigned long)hv_cpu->synic_message_page); - if (hv_cpu->post_msg_page) - free_page((unsigned long)hv_cpu->post_msg_page); + kfree(hv_cpu->clk_evt); + free_page((unsigned long)hv_cpu->synic_event_page); + free_page((unsigned long)hv_cpu->synic_message_page); + free_page((unsigned long)hv_cpu->post_msg_page); } kfree(hv_context.hv_numa_map);