Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11775656rwl; Tue, 3 Jan 2023 04:41:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXvkRQQerRTtnaXffkoHVxBM8Yj+wIuHoPjCstnCujJhqng2oPHnojlN3uuRWb3KPyUaqNQM X-Received: by 2002:a17:902:ea0a:b0:192:6b73:ccee with SMTP id s10-20020a170902ea0a00b001926b73cceemr52161295plg.18.1672749695960; Tue, 03 Jan 2023 04:41:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672749695; cv=none; d=google.com; s=arc-20160816; b=RzhlsxL8MZplTVs9RTXb5MJKBBjA7PnuKXtgBRKdKLYvUNZQJ9GqjPfeFNHpqrBDFi 0tiuKwVYZqp8Denc9hEe16rXhclC2WyzWFeh30HwgCRrBw2GBHPMBcgvV0XwkJxrfuTn SE/U6uOwN1k/TS6hcyqXX6FS3w3UeK9a8OAVxPOZbDT4cr0n+CkYx72JX5luVkbPMYvW 8J/2j670MbeOWBSM1WdX6XFi55nHbtKzdDTJBSJBm0NyNquN3ztAh4tTT4GrKZCyAI5Q 6VkQvl4BBz07xxkzoAq72R84lHTkQDxrpYYvlcvLCXtdKr8mollhVFG214Brkv18iwGf hokw== 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=JfHfxq3lX1f1scaBbnguDJEQzcQB49P5IAxROskdV+Y=; b=gA/6k7UvQUebPH2aQw23J+9TR0Qf4bBjsHcMv/xUSxxsA4mE7Sm29i+nbIM+L6+Igy YWNme/WeD35h+FiETrJKc6x/VB19CFSEaCksPMWu5qGuqhH8tMEQ0E2FivddvOzV7+EO mhbh2fuUGwS/A8Pa0CRvDxeRFNVvvRKN+yNFAJhrN1Fqg57SvLWdUwttW3UAwSVPnYkO xNxixNm5sKZJ2oRMPZoZFyFSmxCfMZ1UWCdAe8mafC/rUAgDKPH/I7o7A3M5dnzLurcN 1iHsjjl6LtZSbQqSJ0gUhMVKy7Ukop6z9bLzwbYV9pINHzAsn1S52/igHnz1LrcjJA39 4Qxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=IKGnRgMp; 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 z11-20020a170903018b00b001782a6fbc7csi19776049plg.463.2023.01.03.04.41.12; Tue, 03 Jan 2023 04:41:35 -0800 (PST) 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=20210112 header.b=IKGnRgMp; 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 S237476AbjACMRZ (ORCPT + 61 others); Tue, 3 Jan 2023 07:17:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230193AbjACMRX (ORCPT ); Tue, 3 Jan 2023 07:17:23 -0500 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 64FB83A0 for ; Tue, 3 Jan 2023 04:17:22 -0800 (PST) Received: by mail-pl1-x62f.google.com with SMTP id g16so22748779plq.12 for ; Tue, 03 Jan 2023 04:17:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=JfHfxq3lX1f1scaBbnguDJEQzcQB49P5IAxROskdV+Y=; b=IKGnRgMpl0f0h7CR06OjOBmJXVNuyPBZdFuYhwyKib57ildXrzfTeCj7jnxdwYBm+O s6eh5WjpxSN/nyh/4VNrNeNwvKsxI+PJbXPOBe+jBMIM6rMqBdeVt33MOWFCZ7WwZY6A FH5HbOL0x2yBF8Y4Ny5C6TnHgYRvPGEvQ47hagVL4mpLX1F1hu8jWPut68MnPGxPDPnN 9R9e8YIuP7zh+udt+1rTkDG+bY0jf0TbxDGjYe+0YoV1ROYY7CrO8c7lkdyJ28v7WXNS DRdj+bz7wLEJg2XTVpIE3hUFo3t/x6Hlm/4BEvP06zt4dxpDA7rtTCBiuC0uovGwxRdI GE4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=JfHfxq3lX1f1scaBbnguDJEQzcQB49P5IAxROskdV+Y=; b=1QMoDW7s+GdegH0J6qW885xsghUtcu+Jauub/8XxnaBg1xwNMrz2yVq9jlyqKH6GhQ 9z1hAxBAAg4oSMFCFY85VcNzJ1jQfqtoKPImq+LRrmWJppkxn3y/oapZaQooNx79LK13 Wte1VEEBIbgnLhGGD+ThmkzX41NkC02V4nsfdn3bcNRmCBTRS7yAiotzYU/ZlbcKa475 sHlcabAxWlaAk9SuOytWRcAu/2PIK5eJjNtYO4wqqmn2CdQfBVtqLoeRSwMK4J7+4T76 pcXrbf/msz+bVajluluLUXQiPDws7a5XE+lDuCw3f8x8QyeqW8iz1DNPXkjhpQMLggEB wvEg== X-Gm-Message-State: AFqh2kpOY8rS/8Rai5os8HH4Fs651vYEcPwOYSRW3HMQge5E9i0OOEB8 fVEWekTaVJqwYyaupfNRh34= X-Received: by 2002:a17:902:d491:b0:192:b40b:e41 with SMTP id c17-20020a170902d49100b00192b40b0e41mr21388428plg.61.1672748241839; Tue, 03 Jan 2023 04:17:21 -0800 (PST) Received: from [192.168.0.105] ([183.254.109.196]) by smtp.gmail.com with ESMTPSA id t8-20020a170902e84800b0017849a2b56asm22174565plg.46.2023.01.03.04.17.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 03 Jan 2023 04:17:21 -0800 (PST) Message-ID: Date: Tue, 3 Jan 2023 20:16:30 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.6.1 Subject: Re: [PATCH] um: vector: Fix memory leak in vector_config To: Anton Ivanov , Geert Uytterhoeven Cc: Richard Weinberger , Johannes Berg , Jakub Kicinski , "David S. Miller" , Wolfram Sang , linux-um@lists.infradead.org, linux-kernel@vger.kernel.org References: <20221229075323.1394010-1-linmq006@gmail.com> Content-Language: en-US From: Miaoqian Lin In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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 On 2023/1/3 18:28, Anton Ivanov wrote: > > On 03/01/2023 08:00, Geert Uytterhoeven wrote: >> Hi Miaoqian, >> >> On Thu, Dec 29, 2022 at 8:53 AM Miaoqian Lin wrote: >>> kstrdup() return newly allocated copy of the string. >>> Call kfree() to release the memory when after use. >>> >>> Fixes: 49da7e64f33e ("High Performance UML Vector Network Driver") >>> Signed-off-by: Miaoqian Lin >> Thanks for your patch! >> >>> --- a/arch/um/drivers/vector_kern.c >>> +++ b/arch/um/drivers/vector_kern.c >>> @@ -765,6 +765,7 @@ static int vector_config(char *str, char **error_out) >>> >>>          parsed = uml_parse_vector_ifspec(params); >>> >>> +       kfree(params); >> Are you sure the memory pointed to by "params" is no longer used? >> "parsed" seems to contain pointers pointing to (parts of) the string >> pointed to by "params", so it cannot be freed. > > +1. > > I was just about to send the same comment. > Oh yes, thanks for spotting this. We should only perform release when uml_parse_vector_ifspec() fails (returns NULL). In this situation, 'params' is no longer used. Do you agree? Thanks, >> >>>          if (parsed == NULL) { >>>                  *error_out = "vector_config failed to parse parameters"; >>>                  return -EINVAL; >> Gr{oetje,eeting}s, >> >>                          Geert >> >> -- >> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org >> >> In personal conversations with technical people, I call myself a hacker. But >> when I'm talking to journalists I just say "programmer" or something like that. >>                                  -- Linus Torvalds >>