Received: by 2002:a05:6358:c692:b0:131:369:b2a3 with SMTP id fe18csp261520rwb; Tue, 25 Jul 2023 15:36:05 -0700 (PDT) X-Google-Smtp-Source: APBJJlHhMO4t5tlGd+n7KjsdfUwipcIMlgN2apMwUBOCHWBZBzYfhPNh1nmD3uhEiT3kXGM0E0Lt X-Received: by 2002:a05:6358:8820:b0:12f:22c1:66aa with SMTP id hv32-20020a056358882000b0012f22c166aamr171130rwb.3.1690324564694; Tue, 25 Jul 2023 15:36:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690324564; cv=none; d=google.com; s=arc-20160816; b=ma0EwGLu9YZSdI2pUk9iGC/pQTNuJnlw7waC9q247kV9gwb09H1ZSC7Y4JKKhr/rVj 413U7vzUf1U1UdLZAtgqFgxmaCA52iZuAS9Q9NcS/UBsOG+trO8AHXavdjxiE1HJrNJq tEfaXhsdASU4Mcmw5ARrlHBLgf6f3Q+cMOyGa9x07wBMm1pgUd1f3L2oxJTc6CPAuyia 5bU5lVn+XjnsifCy/yjkxvttWJEN6AXg+PCVOgsOeIrRgD+Yl4kUn5KavGaVRDirURfU WL85JEl2pN2p6o1Sxl/wYYmWACwWXBsZB1kvvAXrhZnZgyvAc9zbfRSMYg/wYwu4uNw3 iLUQ== 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=YlHDiRN/74XK66bPeSMdSDzuItYNuBd/sWX4Lk9V5K4=; fh=UacUO69mcEnj0l/Sq8pQtbEaDl3n3IL5+ouzhHjbiDo=; b=xaxyfHRWNdBvW0LyBezAxWWHGsvr4zRE1cZDN9+c9b7wVdZSQYoK0G75malec2Hn5L ZNjwNwbHOzx0GMoCLIiVkPoUnosg4ExV7d2goanV+/NtBz3IXWP+TZnCf5jJBfiLBIhK D59+8RsnHA4UEnxeZg575g1vguIDdPhXUoREgB21OrV+G0mGPwrRCGALda5Am28ICpQk 6DCrK2MIWLx9ckdgzC22G2BRM5Wmo94JKU7V7F0lP42+nyHEgwZXFvunuOXtU8FahxTL fYbLNZPHFKsGY8R4Eb9LyDxXOCODtw+HUSPM8u6FWrOE3gVjsp2EyhHj/kRhfhvTHFqM dE4w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="KsOoW0/U"; 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 v22-20020a636116000000b0053b8874cee6si75721pgb.358.2023.07.25.15.35.44; Tue, 25 Jul 2023 15:36:04 -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="KsOoW0/U"; 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 S231689AbjGYWBR (ORCPT + 99 others); Tue, 25 Jul 2023 18:01:17 -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-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 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_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: -- 2.34.1