From patchwork Tue Jul 25 22:00:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Lopez X-Patchwork-Id: 13327102 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA9A2EB64DD for ; Tue, 25 Jul 2023 22:01:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231642AbjGYWBC (ORCPT ); Tue, 25 Jul 2023 18:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231157AbjGYWBB (ORCPT ); Tue, 25 Jul 2023 18:01:01 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5FA97BC; Tue, 25 Jul 2023 15:01:00 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-565db4666d7so3761602eaf.0; Tue, 25 Jul 2023 15:01:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690322459; x=1690927259; 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=lUZnk3BJHa8i4G+I5FHI1a5ZCFbsEeNLgSVmJzgYbxk=; b=XVK1FzTn/TccXCjpTjt4Pf6a69wnwkxxmHdsFbn42YM2M4vBpG1M4prm2pxLW7iMwb uZQbixtobzfmh9gLPJ+pgLfuyfWnGX2TiVWggmdqsfsxE/zrHdbRUbvWB3USqA3bEtMI PjPLe32eJNSaKLmxx4YIeiF2PLzzAHnp7WVo/wPq34UgfQvRjJ34u9jeGQgz1s2qmIvF g9c55G8A1MynG6olwvA77cUcjqSdyAgtw/DVD81YZGnjmZgw9wySkd5jHjom/NPTD9CB w2KU9o+XcURSi03JKAtuk1kts/CReVvTu6TU2tIFkYWvpDhaKbMAKw5EdrM9yFDW4cSL fjhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322459; x=1690927259; 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=lUZnk3BJHa8i4G+I5FHI1a5ZCFbsEeNLgSVmJzgYbxk=; b=UqzTTOJ+IWgBLKsd6Bhm25yfFxoI3b9eAw+7HgWnmaYY/1SMI95fhAwoWSRZutG1Wr v9bvUGsz8DIjAv2IGo3b84NKHt+nGBwXw6C0gXa2ZSBETUmFGT7/6dkls1ioQq2xLt9L cnvKcmcQ5MNAXEPZ4pm8PmMKJdvGSrOoNuHYngOKaaMNUns8wviGb9JTCuOu9KGgBbqP jAyJ06Z3GlwL69TMe+RikjyJKzfZHZhaVZYCqiVVBK2TICltF80TH1e8uDLyuwxpPJRX Q3CsJFE/rVm7t6krd8NNXE6PnGfu3suqNw7znyoTk+V2Zcz6fdtltghWFbJrb+tEZZab Xihg== X-Gm-Message-State: ABy/qLaBvn0FsSAA/W6zK3BtZhMT4xYge6df/VozL5nhuayi7ZuAzqIP g52g3PYGAKe/ZlCC3tNdS3M= X-Google-Smtp-Source: APBJJlFHbPlurwcX03fBvkaEqCG30OPkMJnrFKVl1kvNbFWF5Iu6L7x7GY8nuxej+cWPcjRmow0TZQ== X-Received: by 2002:a4a:3c17:0:b0:565:bbc0:2e36 with SMTP id d23-20020a4a3c17000000b00565bbc02e36mr98675ooa.3.1690322459704; Tue, 25 Jul 2023 15:00:59 -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.00.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 15:00:59 -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 1/5] hp-bioscfg: Fix memory leaks in string_elements_from_package() Date: Tue, 25 Jul 2023 17:00:52 -0500 Message-Id: <20230725220056.25560-2-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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Address memory leaks in hp_populate_string_elements_from_package() and uninitialized variable errors. Signed-off-by: Jorge Lopez --- Based on the latest platform-drivers-x86.git/for-next --- drivers/platform/x86/hp/hp-bioscfg/string-attributes.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c index 1b62e372fb9e..e0ecdfca4def 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/string-attributes.c @@ -133,7 +133,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob char *str_value = NULL; int value_len; int ret = 0; - u32 int_value; + u32 int_value = 0; int elem; int reqs; int eloc; @@ -171,6 +171,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob if (expected_string_types[eloc] != string_obj[elem].type) { pr_err("Error expected type %d for elem %d, but got type %d instead\n", expected_string_types[eloc], elem, string_obj[elem].type); + kfree(str_value); return -EIO; } @@ -232,6 +233,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob str_value, sizeof(string_data->common.prerequisites[reqs])); kfree(str_value); + str_value = NULL; } break; @@ -250,6 +252,7 @@ static int hp_populate_string_elements_from_package(union acpi_object *string_ob } kfree(str_value); + str_value = NULL; } exit_string_package: From patchwork Tue Jul 25 22:00:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Lopez X-Patchwork-Id: 13327103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65CB3EB64DD for ; Tue, 25 Jul 2023 22:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231404AbjGYWBK (ORCPT ); Tue, 25 Jul 2023 18:01:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231652AbjGYWBD (ORCPT ); Tue, 25 Jul 2023 18:01:03 -0400 Received: from mail-oa1-x33.google.com (mail-oa1-x33.google.com [IPv6:2001:4860:4864:20::33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7F3BC; Tue, 25 Jul 2023 15:01:02 -0700 (PDT) Received: by mail-oa1-x33.google.com with SMTP id 586e51a60fabf-1bba1816960so680462fac.3; Tue, 25 Jul 2023 15:01:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690322461; x=1690927261; 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=xUKWe23SezTiM/kRUdKBl5wmSf4mUZBR+Z+CLpUrp98=; b=H+d1jGajJSEzB3DvvT22YBnAf0zVpenbkl00bJpOlYhvKDQGRxnHB/z99wTBpVQGdu dwNmghwF+rGPqJ18uIg7Fiw4GokkurKyCkhtPejeI2YousXpG8bpEdFmNrsHXICE8+Gv YLLhieE7+OCxoq7vxVQ3BAFRrMs8FY4+cKkWBp+hRNUrOwevCFuxYSbs0J6CbxIPIWrO gUajJ2H6AoQmX3UfU+wO6d1FOesOWvTqcWPSi1x+QgOsl0DcuC8dGcWai98H7tmr5kzv /du5AfOLoP3cyxNKt0mtsJO+EXB2LOqf/ypmR7412uiWXxr/zlkYfdFJb6d+SMs7dx57 uqeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322461; x=1690927261; 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=xUKWe23SezTiM/kRUdKBl5wmSf4mUZBR+Z+CLpUrp98=; b=VYz8LGkG9YU5i2MkL0uVtB8Zw/kA8/OH68Sk/c1IWqZODOEPxzufBX45rasdEyq0l2 Td9X+vbRypdghclNl15xR6lvrKCOxD1IoVxjAanjbFBCWSJPfclHREFlcjB/QUynGiZ2 Sz6xAZUl+NTUx/TXG3CyTeabaHyzcdIHitTjTfXCqtUryHuOW/19mlkcCaMuqtDk3B/m 9U9XfmNLBDV33vf2Mt0MxpynI1umEbvjhJnG1FrzKhjX3hCWmCH2uA8eT3K1aw98uoKW D73f9pggMODGclb4BwEMrZFdat3ZWsBp3XjEETXCIgkYm62zK9YdUxEmKnW7w5eB/ag9 czgQ== X-Gm-Message-State: ABy/qLZwWBEZGqapQ/B/Dr+YcSVlV5sLJ/64ENgU8Dc8PSIvm5h5nw7F yQo3nCjJNxM9HDDG6Yu6CVUSrv/WnJc= X-Google-Smtp-Source: APBJJlGs8e+BcZoeIS7Ta8OdSTKkN/L7RoS80xB2EO9r2yWa13JhAScPI++JItWed+digROGv9kQqA== X-Received: by 2002:a05:6870:40ca:b0:1b7:6158:621a with SMTP id l10-20020a05687040ca00b001b76158621amr370690oal.47.1690322461369; Tue, 25 Jul 2023 15:01:01 -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.00.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 15:01:01 -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 2/5] hp-bioscfg: Fix memory leaks in ordered_list_elements_from_package Date: Tue, 25 Jul 2023 17:00:53 -0500 Message-Id: <20230725220056.25560-3-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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Address memory leaks in hp_populate_ordered_list_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/order-list-attributes.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c index 7e49a8427c06..89e67db733eb 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c @@ -131,10 +131,10 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord int instance_id) { char *str_value = NULL; - int value_len; + int value_len = 0; int ret; u32 size; - u32 int_value; + u32 int_value = 0; int elem; int reqs; int eloc; @@ -174,6 +174,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord if (expected_order_types[eloc] != order_obj[elem].type) { pr_err("Error expected type %d for elem %d, but got type %d instead\n", expected_order_types[eloc], elem, order_obj[elem].type); + kfree(str_value); return -EIO; } @@ -231,6 +232,7 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord sizeof(ordered_list_data->common.prerequisites[reqs])); kfree(str_value); + str_value = NULL; } break; @@ -277,13 +279,17 @@ static int hp_populate_ordered_list_elements_from_package(union acpi_object *ord part = strsep(&part_tmp, SEMICOLON_SEP); } + kfree(str_value); + str_value = NULL; break; default: pr_warn("Invalid element: %d found in Ordered_List attribute or data may be malformed\n", elem); break; } kfree(tmpstr); + tmpstr = NULL; kfree(str_value); + str_value = NULL; } exit_list: From patchwork Tue Jul 25 22:00:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Lopez X-Patchwork-Id: 13327104 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D999C001DF for ; Tue, 25 Jul 2023 22:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231674AbjGYWBL (ORCPT ); Tue, 25 Jul 2023 18:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230469AbjGYWBE (ORCPT ); Tue, 25 Jul 2023 18:01:04 -0400 Received: from mail-oo1-xc35.google.com (mail-oo1-xc35.google.com [IPv6:2607:f8b0:4864:20::c35]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0022E0; Tue, 25 Jul 2023 15:01:03 -0700 (PDT) Received: by mail-oo1-xc35.google.com with SMTP id 006d021491bc7-5634d8d1db0so3836682eaf.0; Tue, 25 Jul 2023 15:01:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690322463; x=1690927263; 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=QX7T2RPgbuYmgoQOJwoEsgAUtn61DiADmPjBuL7fWDc=; b=hFVnEW+UvIkZfF9U6GFwGnUmRFoV5LNdQd7RH61zvA4z8nURZU4gp3EszcF63CMdI0 FygbNn7LHdbZ5MBZFW+YcdR8ndLv98WAgRJPj673nOrK1e3iTpgW/2Jn/507ZlaOw32w JfRENeqIqwMfPFTa8U7Goo/9WIYxrHYSrxAVHJfl5lbHD6ewUthSxKNXst56HxOA9abw 6day8S0+bW6+KdGQWYYxRAHIouf8XH4zqWBvJeza0DYEvIjEi0+D18UXxWSSooW26wOe cuPpHWDHnKhrJD5Ce/OayN1cuxnAnoCYArLZtPB36035XIKy/9RD4eg5F2Sj3H4Nt0rE 0r/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322463; x=1690927263; 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=QX7T2RPgbuYmgoQOJwoEsgAUtn61DiADmPjBuL7fWDc=; b=J0cXrQGfn0wrsIofuIb3mo85XbFRTOTsZqwAMJYoLEzJR4/VLrxxgnEvAar+6CiaER iFpTDSm20XBt0nSOSavJL1G/1qMG/EvsU+zrqjTQVrCtLBVAmoXA7LD/ZUUb+x2JDHVL hpZ+XsCIgCRl2XO05rpcKWq1vb36F7UlIbN3CnW4H5/raCdTGHkNmc5sAOYJ32ALAKMb le6VmQsNNguZ6UjcXxqH3KjE+eHzqUBew8eSjapTHIyxxEde7mmEkTrxnfYyOwdhkVxP QpT3a3/s7unehDHJ/U6o7ezaUaVhaW74LGFQ1DApJmHb+jxvWoxVuNTDATr9q2BOyHh5 jtMQ== X-Gm-Message-State: ABy/qLYW0HapcZrSYZ2pT9dybN0Kp0fig8bx0T3stUq18As55sie4gF2 RY3u/Mx55htzDCpp/eYdHys= X-Google-Smtp-Source: APBJJlHYOTWAkHaNlbdB4sQSR8mFdK35EDIebnNZ3A0a3Pih3TclyM3kSYF439JcIVzJh2yxtFrfww== X-Received: by 2002:a4a:3107:0:b0:566:fcc8:5b6e with SMTP id k7-20020a4a3107000000b00566fcc85b6emr79987ooa.6.1690322463049; Tue, 25 Jul 2023 15:01:03 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 15:01:02 -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 3/5] hp-bioscfg: Fix memory leaks in integer_elements_from_package Date: Tue, 25 Jul 2023 17:00:54 -0500 Message-Id: <20230725220056.25560-4-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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Address memory leaks in hp_populate_integer_elements_from_package() and uninitialized variable errors. Signed-off-by: Jorge Lopez --- Based on the latest platform-drivers-x86.git/for-next --- drivers/platform/x86/hp/hp-bioscfg/int-attributes.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c index 7364c5ef9ef8..97f88e0ef0cc 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/int-attributes.c @@ -143,7 +143,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ char *str_value = NULL; int value_len; int ret; - u32 int_value; + u32 int_value = 0; int elem; int reqs; int eloc; @@ -179,6 +179,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ if (expected_integer_types[eloc] != integer_obj[elem].type) { pr_err("Error expected type %d for elem %d, but got type %d instead\n", expected_integer_types[eloc], elem, integer_obj[elem].type); + kfree(str_value); return -EIO; } /* Assign appropriate element value to corresponding field*/ @@ -239,6 +240,7 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ str_value, sizeof(integer_data->common.prerequisites[reqs])); kfree(str_value); + str_value = NULL; } break; @@ -258,6 +260,9 @@ static int hp_populate_integer_elements_from_package(union acpi_object *integer_ pr_warn("Invalid element: %d found in Integer attribute or data may be malformed\n", elem); break; } + + kfree(str_value); + str_value = NULL; } exit_integer_package: kfree(str_value); From patchwork Tue Jul 25 22:00:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Lopez X-Patchwork-Id: 13327106 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C60B5C0015E for ; Tue, 25 Jul 2023 22:01:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231699AbjGYWBL (ORCPT ); Tue, 25 Jul 2023 18:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231663AbjGYWBF (ORCPT ); Tue, 25 Jul 2023 18:01:05 -0400 Received: from mail-oo1-xc31.google.com (mail-oo1-xc31.google.com [IPv6:2607:f8b0:4864:20::c31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BFE2C10F7; Tue, 25 Jul 2023 15:01:04 -0700 (PDT) Received: by mail-oo1-xc31.google.com with SMTP id 006d021491bc7-56597d949b1so3705463eaf.1; Tue, 25 Jul 2023 15:01:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690322464; x=1690927264; 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=YlHDiRN/74XK66bPeSMdSDzuItYNuBd/sWX4Lk9V5K4=; b=KsOoW0/UYyCasvjpUcBWZGybkq77ggoF64/KVTROZHUg7t4UsJHRhNJhFDaCaJHmT+ mbS2cKxdL+VcKh1Tkgg9OAO4+b1/os+zBgduv1/4TCNUbID9oNrwl+BKKshjntdAP0wX jmF6tom/PS4EXxGSdIoRPFb4IBGV5OHOfY+IntfdGIbWMCIHTyTBLzILazAiEfdn2Uv+ GQPmw1muwn0GzkhnKYuBo+31b0r1DfuN8V/UDbgSbS0N9Aie9eQK4nxd48ACx2UmZ+5p Tm/A6x99m4ZyuNJK2RZXRhvA2BiCT6kX6foiUMx9oJgFJWDqb9UmFlgZfl4ZcpVmtcHI ocQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690322464; x=1690927264; 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=YlHDiRN/74XK66bPeSMdSDzuItYNuBd/sWX4Lk9V5K4=; b=XyTB/fz5SjrEKH9/LIoI7BiYvS5MKj5EEHUa5I+Ke7SO7JohLUAJGmT2HCOpn+d5gz HmI259XD/jsmj4Ov8SVqg3v4rNgBf/H5sw9ce0OQ1eKh+upZGUv068nPdkOHspphq80r vK88zASILZ8uGol5f6pejgIzUIyZULiQKlzknrHTCiRLey1ffKzPGbJ9IFUkMVqA7ufq SHbBL1HsJ6ntQLsYCHxAcdR3TMNHruiUQ+9Dlk/1zwVRfD4fGjHqPaYD6MWqnAbRb8g8 /JW7TcLzs1BVeXo5RFlaj79QRHgwaBWeGlaVtVjz9BLtMLN2wap6seNCaEt+Ec5Z1S09 g4/Q== X-Gm-Message-State: ABy/qLbypEYva8Dmcaff0xjeKTrpl7vT0MkA735sFe04vfSu7m3N6S8V 9+/+/gOuqLfKWiwHFLwkde0= X-Google-Smtp-Source: APBJJlFlASPlPNtudufA2pchYAMlHntVETCvEJzLhbTM7Wk4vs2JCz22sHcADZZ/gWVfMi3xK6HMeg== X-Received: by 2002:a4a:344a:0:b0:566:f763:8fb7 with SMTP id n10-20020a4a344a000000b00566f7638fb7mr88949oof.2.1690322464072; Tue, 25 Jul 2023 15:01:04 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jul 2023 15:01:03 -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 4/5] hp-bioscfg: Fix memory leaks in enumeration_elements_from_package() Date: Tue, 25 Jul 2023 17:00:55 -0500 Message-Id: <20230725220056.25560-5-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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@vger.kernel.org Address memory leaks in hp_populate_enumeration_elements_from_package() and uninitialized variable errors. Signed-off-by: Jorge Lopez --- Based on the latest platform-drivers-x86.git/for-next --- drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c index b1b241f0205a..7f77963cd7fa 100644 --- a/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c +++ b/drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c @@ -129,7 +129,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum char *str_value = NULL; int value_len; u32 size = 0; - u32 int_value; + u32 int_value = 0; int elem = 0; int reqs; int pos_values; @@ -164,6 +164,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum if (expected_enum_types[eloc] != enum_obj[elem].type) { pr_err("Error expected type %d for elem %d, but got type %d instead\n", expected_enum_types[eloc], elem, enum_obj[elem].type); + kfree(str_value); return -EIO; } @@ -224,6 +225,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum sizeof(enum_data->common.prerequisites[reqs])); kfree(str_value); + str_value = NULL; } break; @@ -275,6 +277,9 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum strscpy(enum_data->possible_values[pos_values], str_value, sizeof(enum_data->possible_values[pos_values])); + + kfree(str_value); + str_value = NULL; } break; default: @@ -283,6 +288,7 @@ static int hp_populate_enumeration_elements_from_package(union acpi_object *enum } kfree(str_value); + str_value = NULL; } exit_enumeration_package: From patchwork Tue Jul 25 22:00:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jorge Lopez X-Patchwork-Id: 13327105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1DB52C41513 for ; Tue, 25 Jul 2023 22:01:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231300AbjGYWBM (ORCPT ); Tue, 25 Jul 2023 18:01:12 -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-Google-Smtp-Source: APBJJlFBn5vUqnknyj718FC81NIV4HcjANhJsE9UmdaArbL635it94NRx9qBhd84aRQf57NOAGh68w== 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 Precedence: bulk List-ID: X-Mailing-List: platform-driver-x86@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: