Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp11696303rwl; Tue, 3 Jan 2023 03:26:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXuZy1uiQ6HiG/jkkT35oHgviqb8woQh1rJUTTwKAI0ls4aDb18DykL3wnVVgCotKNBrwDw6 X-Received: by 2002:a05:6a21:3a48:b0:ad:5cde:5beb with SMTP id zu8-20020a056a213a4800b000ad5cde5bebmr53355257pzb.47.1672745218730; Tue, 03 Jan 2023 03:26:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672745218; cv=none; d=google.com; s=arc-20160816; b=rhZqGUNd+VRGm4zQcoG/c/KOlBklDYriYWBNMuq/a8piLkKl6n2xIUjSwQZTZMoGm7 i2BGkc5rA7YM3grOAviVkAZouq2FF9QqBX2cX6JuUV5eTPDw5Rx5nnRBxWIz8fM7Qoyo sDWPyGYKOVpiylTCMg9RC0gyeVhIoZNkGbvuBQCDQ1BqmBTFBq32RP5UQlyYPWiupwgF GhZKA7+P5b71R5qS0htPbXrYIJCCUi0pyK3zeD52tJ6+Bs5iPUBzLYe/zlWvh32qw2Ll pLCkLf4DUvf6sWVeVC+RgCc5t+rzA3+VhUEcnUwdBlVov3BwHj77k1Es/3H1hQ0xbf/k F4fg== 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 :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=VTZt9oiyVVYnq5YpZmAtBrATb70W7wFb9GxWJRI1nrM=; b=BmU/SN3AMNvZ4/KlmJJgYQoT7X409242Hbo4wfOr3WxdecEZONAvbIFZbwrXN3fj0p dWtZ6DMd3rW+K0byrubwHlglhhi6+pXu5vXb3aYi4r4j0ztb7ZE98NRb+hvMn3Ri3Rbv DG/p+DspI7gCzZybz/sCRDeaMex1rl7FSVxNfXALLldPIyl0t7hEaxQSPz8lKEivQXZw 72G6kNLWTWXnMPP0M4KRso+Vj1FhI7gfpqvsni2T+2ow9Trh6I+ebjSdP66/TVu6Uni/ kfN/kVhR9yvKLZ9nVvicGhnfmpiQB+cuPAijX859eJ1HnkB4d95Mp2XuQsPFtkmPh9fx w6CQ== ARC-Authentication-Results: i=1; mx.google.com; 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 y12-20020a655a0c000000b004404162e5e0si32864108pgs.593.2023.01.03.03.26.50; Tue, 03 Jan 2023 03:26:58 -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; 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 S233082AbjACLDO (ORCPT + 61 others); Tue, 3 Jan 2023 06:03:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237476AbjACLCx (ORCPT ); Tue, 3 Jan 2023 06:02:53 -0500 X-Greylist: delayed 1988 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 03 Jan 2023 03:02:34 PST Received: from www.kot-begemot.co.uk (ns1.kot-begemot.co.uk [217.160.28.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4503310D9 for ; Tue, 3 Jan 2023 03:02:33 -0800 (PST) Received: from [192.168.17.6] (helo=jain.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pCeXF-005C2N-6D; Tue, 03 Jan 2023 10:28:45 +0000 Received: from jain.kot-begemot.co.uk ([192.168.3.3]) by jain.kot-begemot.co.uk with esmtp (Exim 4.94.2) (envelope-from ) id 1pCeXB-004VNL-Fn; Tue, 03 Jan 2023 10:28:44 +0000 Message-ID: Date: Tue, 3 Jan 2023 10:28:41 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.13.0 Subject: Re: [PATCH] um: vector: Fix memory leak in vector_config Content-Language: en-US To: Geert Uytterhoeven , Miaoqian Lin 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> From: Anton Ivanov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Score: -2.0 X-Spam-Score: -2.0 X-Clacks-Overhead: GNU Terry Pratchett X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 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. > >> 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 > -- Anton R. Ivanov Cambridgegreys Limited. Registered in England. Company Number 10273661 https://www.cambridgegreys.com/