From patchwork Thu May 20 09:22:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 445465 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3002C43461 for ; Thu, 20 May 2021 10:43:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 872B0610A1 for ; Thu, 20 May 2021 10:43:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237630AbhETKpP (ORCPT ); Thu, 20 May 2021 06:45:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:44304 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237450AbhETKnM (ORCPT ); Thu, 20 May 2021 06:43:12 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C580D613BB; Thu, 20 May 2021 09:56:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621504598; bh=kaakvcBm3EUSwPhuc6Q9/zGlpRcyDZIi9PKl0Y1AXHw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9uVK5gC4sB3qBUIJkvTok/YmeL6GWp3SsK/PiKjVBufHzd692Vx7ahjCbkIyMTtA uIlKaN9iWHs+BvkezFWmyTM3qw+OfxBCiVQW+5zwAopvBQvgAo1vEitBV5fc/7hEd/ fw7N/bVXSm9TVfPmm6cRyyZEwib0nDEB0ocPrxbk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe JAILLET , Andy Shevchenko , "Rafael J. Wysocki" , Sasha Levin Subject: [PATCH 4.14 284/323] ACPI: scan: Fix a memory leak in an error handling path Date: Thu, 20 May 2021 11:22:56 +0200 Message-Id: <20210520092129.958784547@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092120.115153432@linuxfoundation.org> References: <20210520092120.115153432@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Christophe JAILLET [ Upstream commit 0c8bd174f0fc131bc9dfab35cd8784f59045da87 ] If 'acpi_device_set_name()' fails, we must free 'acpi_device_bus_id->bus_id' or there is a (potential) memory leak. Fixes: eb50aaf960e3 ("ACPI: scan: Use unique number for instance_no") Signed-off-by: Christophe JAILLET Reviewed-by: Andy Shevchenko Signed-off-by: Rafael J. Wysocki Signed-off-by: Sasha Levin --- drivers/acpi/scan.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 57a213466721..11f07f525b13 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -704,6 +704,7 @@ int acpi_device_add(struct acpi_device *device, result = acpi_device_set_name(device, acpi_device_bus_id); if (result) { + kfree_const(acpi_device_bus_id->bus_id); kfree(acpi_device_bus_id); goto err_unlock; }