Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp234132rwb; Tue, 25 Jul 2023 15:04:26 -0700 (PDT) X-Google-Smtp-Source: APBJJlGa5kQGgQgHQ6ySmAJsvvzjzZT/TcAWnHau3qzlleTSarIDEwlFGfpgvgjb0Edy5Xx0OwwP X-Received: by 2002:a17:902:7d97:b0:1b8:b464:fa1d with SMTP id a23-20020a1709027d9700b001b8b464fa1dmr279421plm.69.1690322666191; Tue, 25 Jul 2023 15:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690322666; cv=none; d=google.com; s=arc-20160816; b=byPbKaZ7lkzc3aoC9RppE6WG496VE81KPtRllOLlhkUv13lFcy6MTRJbiDnmIU3L+s 8RkoX6wGmjeNU89QsczSZ/esx5JYTc8s+2yh21lHt5/p8hmLGFcfWvjY14HoynCZ19hf Gk+VKtoVHs0vt8KAxlkbA9E0s8fCCwM/jCDF4B3gmQyEPaqiYVHqX9XLjMyMZSc8UlOD L1r9NwChw6F8OljtAIzAG8+ygR4+e/k/DaZDBWfktPjlSuyt6lGONavLZZtDn7rsGLK8 gQnglnk+sizvbcgK2pnDMcS9wlgGFDoc8VrYHfE1qfPWlrRyMSe3YgU2cOhiY2GcsPmS frRw== 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 :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=sNrWzLvwqEWfm83K2uRioAjV1pOkPLb6ELuVS9z3syU=; fh=UacUO69mcEnj0l/Sq8pQtbEaDl3n3IL5+ouzhHjbiDo=; b=KIRntMud3eLt+8RKqF+qhyMTCeXRD8i2/LHUo7Ub8k/JfYgZ0+EqjY4Jhoj6T21pqH FMatjd0KOcEsSQQ6LtW3l7Wdw1Wrlf00JWWMkAg1CeUXe+2FfWuPKrt8pbBYt5v6jzvq 6fPPiXF5RchcBomepINPGm8F9vTekSFo5BvdlyiHSVrGh4n61Dv/OrZebHkZQEAIRJsZ kvvTM7WwYkT70QUMYRwpMicMm9uvB3Ya2SlZHTpzQ7YVEcQolWlQVuYagruoHI1vVYvH 9Bh+lpIWfNTMW7rUPWqV4Vbwb/JCS1zPb5KHEYQ5rM+CI3ApPZfx+quFcCQJzQwHfD6j +z0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=h+XCLvqs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j7-20020a170903024700b001b9e21bc14dsi12597659plh.652.2023.07.25.15.04.12; Tue, 25 Jul 2023 15:04:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=h+XCLvqs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231705AbjGYWBW (ORCPT + 99 others); Tue, 25 Jul 2023 18:01:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231665AbjGYWBJ (ORCPT ); Tue, 25 Jul 2023 18:01:09 -0400 Received: from mail-oa1-x35.google.com (mail-oa1-x35.google.com [IPv6:2001:4860:4864:20::35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A82E1FEC; Tue, 25 Jul 2023 15:01:06 -0700 (PDT) Received: by mail-oa1-x35.google.com with SMTP id 586e51a60fabf-1bba254a7d4so650191fac.2; Tue, 25 Jul 2023 15:01:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690322465; x=1690927265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=sNrWzLvwqEWfm83K2uRioAjV1pOkPLb6ELuVS9z3syU=; b=h+XCLvqsjKeM7GRAO2yvRxh7nYDqyHfpp/xhltHZEyOy8xi3kh4p/43Kca21j94dN3 JU8KtiHQXU4S4xjhu+I9+HYE/8vAyKznNDmTb6vbWUeRTF/Vixp8ulGmxFFBwZmHeJhs ObLpFFZoRkY1Fgfju5iYjyYTzZSZw4bYq7pa61HP8/1q5YpMXb3Cbarj9T7x0DJQIIek YctXQDYeVsUTwwxLGniQE1Hkw+gQzI1j1HWuGsk+DYB/rUMNzt6MjJLoeSn+InVoITnY QeiUrhezi3i79M66btXVMDqFtwBK00QXUI5qUSrxvUefTJDQcnZL6F7dmIQP3r3HuuZq xULw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322465; x=1690927265; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sNrWzLvwqEWfm83K2uRioAjV1pOkPLb6ELuVS9z3syU=; b=TZ6gmXxHOEVbXBPNmyx78mDlIr1P6hKRtMW5dOw4n/pkW9Kil7CLz/TSaCZ5PJt1jx ShzaN2Z1B40gjKdjTzv2UUUvGg9kM0KCiExxzWVWrh7Ht3hsQdXz5XXMBiP/d4u8j4n6 cPHJvlp9hPbb4ayZAfV1JCI8euHyMgrGFlp/nXIH1ximtsfeugUi0R9bfOi0kkR4VpEe LH2aTzmasBER1QjohYVL0QEdIMrR9vAphWn0QKgAEjZioSsFKo76tHQGo60Y8ls9h/CZ G0q4mFC9G28juy8nsGRz9bI/5TdcTgckM/OR9gvF/Yj5KFZYAWITcB7anFDjEk9OnwqI Nb0Q== X-Gm-Message-State: ABy/qLaNcXlUYhMnmHVQJBm0ZivwY2w4V65EvKGbSUMxdr+Qn3mwYcAo GKDG7jloJQu0VZm6Gx3JHRo= X-Received: by 2002:a05:6870:f615:b0:1b0:5bf7:3bac with SMTP id ek21-20020a056870f61500b001b05bf73bacmr366061oab.37.1690322465502; Tue, 25 Jul 2023 15:01:05 -0700 (PDT) Received: from grumpy-VECTOR.hsd1.tx.comcast.net ([2601:2c3:480:7390:871d:ebb3:c6e2:8ac3]) by smtp.gmail.com with ESMTPSA id v40-20020a4a8c6b000000b0056688eea98csm5870026ooj.27.2023.07.25.15.01.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 15:01:04 -0700 (PDT) From: Jorge Lopez X-Google-Original-From: Jorge Lopez To: hdegoede@redhat.com, platform-driver-x86@vger.kernel.org, linux-kernel@vger.kernel.org, thomas@t-8ch.de, ilpo.jarvinen@linux.intel.com Subject: [PATCH 5/5] hp-bioscfg: Fix memory leaks in password_elements_from_package() Date: Tue, 25 Jul 2023 17:00:56 -0500 Message-Id: <20230725220056.25560-6-jorge.lopez2@hp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230725220056.25560-1-jorge.lopez2@hp.com> References: <20230725220056.25560-1-jorge.lopez2@hp.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Address memory leaks in hp_populate_password_elements_from_package() and uninitialized variable errors. Signed-off-by: Jorge Lopez --- Based on the latest platform-drivers-x86.git/for-next --- .../platform/x86/hp/hp-bioscfg/passwdobj-attributes.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c index 52e4d346b529..5e833ea0c5e3 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c @@ -227,7 +227,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor int value_len; int ret; u32 size; - u32 int_value; + u32 int_value = 0; int elem; int reqs; int eloc; @@ -264,6 +264,7 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor if (expected_password_types[eloc] != password_obj[elem].type) { pr_err("Error expected type %d for elem %d, but got type %d instead\n", expected_password_types[eloc], elem, password_obj[elem].type); + kfree(str_value); return -EIO; } @@ -318,6 +319,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor sizeof(password_data->common.prerequisites[reqs])); kfree(str_value); + str_value = NULL; + } break; case SECURITY_LEVEL: @@ -356,6 +359,8 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor str_value, sizeof(password_data->encodings[pos_values])); kfree(str_value); + str_value = NULL; + } break; case PSWD_IS_SET: @@ -365,6 +370,9 @@ static int hp_populate_password_elements_from_package(union acpi_object *passwor pr_warn("Invalid element: %d found in Password attribute or data may be malformed\n", elem); break; } + + kfree(str_value); + str_value = NULL; } exit_package: -- 2.34.1