Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7175067rwp; Tue, 18 Jul 2023 11:06:49 -0700 (PDT) X-Google-Smtp-Source: APBJJlFQGu/kkqA93ZVqF42lwJd+FkltP+mVZLA7h3cckRe7rrvz1JRBgIn+NpLY/N9oeQqkON1c X-Received: by 2002:a05:6a20:4312:b0:111:77cf:96dd with SMTP id h18-20020a056a20431200b0011177cf96ddmr10531819pzk.5.1689703609265; Tue, 18 Jul 2023 11:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689703609; cv=none; d=google.com; s=arc-20160816; b=ukvmb4/k4KTQG4nOfHpA90LeCz46r5sjfWF51H3oniFPJ6ByVqQZDl794vXILsOtHI YI3y2i8ljbv94vfq7Z8aQQhmToZFhwYiuj03wa1AfN47Ms3pJY7jB/amaom01Saitvty c9Qs8aru7/wt1IBlVRHmGhxtv8bjkDVb1XLfFd7iCf/UVQZCrK9fhthQvZlyhze21yiT UVCBHgSUz81zGkB2q/+Y9x/Cl1W2ZqejOHpeaT8CZ0vk0v0X5SidQ3ArPSxKL0lB4Icy RKLLP2trqkmNroGVt0CJHZtDAE6RLuIwCq0b5EzoMzxWYW9gRIZVRk2+fcLutQAXSAkY 4HBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=lsbpuBE8VHQOk+U0aT8eLugmaMO5aLTU5RhBZUcQCX8=; fh=bDygPCmTYBSH3RdssCY+qfKpzp551dSf834eM7BF+Zo=; b=eEGbr5MuK9ofwt+3NMebuU93KcnYY33dc8eTsmI13+vUY4KEHKGze3+B4DpB8LCWXs QQe6nyfXR4AB1YAMksEDXbF3NRNypMFy51s+Av7AE+HUgO+EgxBqENxKjOymhDoKzDB2 Vz/UjdO4gKYGVqSllwmRtdJWIGvWbbwWRDGDvzsBI2YbMaWW+Hhi7nJm/BdYeHptQDU/ rZYVLxghL/MKZaKncUtCyFC9OcvSXPI8GwhgqBrJswXDHMG28kLXJUtWPOSmLDMF5aq3 EHyiR9fnTipoojJIJhIwyPwVza9PeMcPE6dqB1gq2sHiEVzdHK7byDXKzugA3dHKC5Tj /xGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@wanadoo.fr header.s=t20230301 header.b=mEo2o3dO; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 73-20020a63014c000000b0055c950412efsi1912846pgb.846.2023.07.18.11.06.35; Tue, 18 Jul 2023 11:06:49 -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=@wanadoo.fr header.s=t20230301 header.b=mEo2o3dO; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230233AbjGRRhB (ORCPT + 99 others); Tue, 18 Jul 2023 13:37:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231173AbjGRRhA (ORCPT ); Tue, 18 Jul 2023 13:37:00 -0400 Received: from smtp.smtpout.orange.fr (smtp-28.smtpout.orange.fr [80.12.242.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A66D4F7 for ; Tue, 18 Jul 2023 10:36:57 -0700 (PDT) Received: from [192.168.1.18] ([86.243.2.178]) by smtp.orange.fr with ESMTPA id Lod3qCbotZWkDLod3qY9dM; Tue, 18 Jul 2023 19:36:55 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wanadoo.fr; s=t20230301; t=1689701815; bh=lsbpuBE8VHQOk+U0aT8eLugmaMO5aLTU5RhBZUcQCX8=; h=Date:Subject:To:Cc:References:From:In-Reply-To; b=mEo2o3dOjfpSc7tohZnxrCKfQQXNP+wPQNnWeSxlxysT4XHzZDYOFaoNEDfD6EgF7 ukEPqxO4BonkifqpWMW6vT9kpUGZjdYK9UrcvIRdpBMv7kwLnGaXbbD85MVoRfe2Lk CWCWiL7WFr5kuomFPXCZqtTp8fV3YsoCMxmBKvmsOtkYRz4gpK0ikmKjUnl8Ldggpr 1D7ATER6Nuwouc0n+I6da0sj0UHZ+A0Xiw9vd3GtPXML/B4ZtsmbkL1+6w202PxEj5 qY1cKEn4BfLlP8+zBAklk56kyYvJEPXT2ztE16dR6kFcjmvkaLP/0onbPNgir7iZJy TlXy+o4QsbEkg== X-ME-Helo: [192.168.1.18] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Tue, 18 Jul 2023 19:36:55 +0200 X-ME-IP: 86.243.2.178 Message-ID: <8d98b544-6191-53ce-fcb7-07d932c40f82@wanadoo.fr> Date: Tue, 18 Jul 2023 19:36:53 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH] platform/x86: hp-bioscfg: Fix some memory leaks in hp_populate_enumeration_elements_from_package() To: Dan Carpenter Cc: Jorge Lopez , Hans de Goede , Mark Gross , =?UTF-8?Q?Thomas_Wei=c3=9fschuh?= , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, platform-driver-x86@vger.kernel.org References: <9770122e4e079dfa87d860ed86ba1a1237bcf944.1689627201.git.christophe.jaillet@wanadoo.fr> <81fd0ef0-e254-4a24-a88a-459b1d773354@kadam.mountain> Content-Language: fr From: Christophe JAILLET In-Reply-To: <81fd0ef0-e254-4a24-a88a-459b1d773354@kadam.mountain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,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 Le 18/07/2023 à 09:55, Dan Carpenter a écrit : > On Mon, Jul 17, 2023 at 10:53:37PM +0200, Christophe JAILLET wrote: >> In the loop in the ENUM_POSSIBLE_VALUES case, we allocate some memory that >> is never freed. >> >> While at it, add some "str_value = NULL" to avoid some potential double >> free. >> >> Fixes: 6b2770bfd6f9 ("platform/x86: hp-bioscfg: enum-attributes") >> Signed-off-by: Christophe JAILLET >> --- >> /!\ Speculative /!\ >> >> This patch is based on analysis of the surrounding code and should be >> reviewed with care ! >> >> /!\ Speculative /!\ > > I reported these bugs yesterday. Ok, seen now... ... but I don't read platform-driver-x86@vger.kernel.org :) CJ > I don't think this is the correct fix. > I thought about making the str_value local to the for loop. That's sort > of like what your patch does. But I wasn't sure that was necessarily > correct either. > > This code needs more testing as well. It seems no one has called this > function. > > Smatch complained about uninitialized variables as well. I didn't > bother to report that yesterday but I may as well. > > regards, > dan carpenter > > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:188 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:191 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:194 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:197 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:200 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:239 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:242 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/string-attributes.c:245 hp_populate_string_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:192 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:195 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:198 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:201 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:204 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:238 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:242 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/order-list-attributes.c:262 hp_populate_ordered_list_elements_from_package() error: uninitialized symbol 'value_len'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:198 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:201 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:204 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:207 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:246 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:249 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:252 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/int-attributes.c:255 hp_populate_integer_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:180 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:183 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:186 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:189 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:192 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:231 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/enum-attributes.c:239 hp_populate_enumeration_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:279 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:282 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:285 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:288 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:291 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:324 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:327 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:330 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:333 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. > drivers/platform/x86/hp/hp-bioscfg/passwdobj-attributes.c:362 hp_populate_password_elements_from_package() error: uninitialized symbol 'int_value'. >