From mboxrd@z Thu Jan 1 00:00:00 1970 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 76099C46467 for ; Tue, 3 Jan 2023 11:03:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229673AbjACLDO (ORCPT ); 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-Clacks-Overhead: GNU Terry Pratchett 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/ From mboxrd@z Thu Jan 1 00:00:00 1970 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E7DADC3DA7D for ; Tue, 3 Jan 2023 12:24:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To:Subject: MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=80VPbK/2JYfQWCVMYpE6iLYos7A9xLmaOf7xKLB4lJE=; b=V/MZqdjh6nWZqf yQEHIsS++TBHQsI7aBwnjVJrfRHZ+xFR+cLULQHRkYCZF45KptSdx5PnbXVvKcGiDdfwun6nmHKSA fciCiqX2AN9ExDl7WuAO3ppRipleJA6m4dckvu9uWZIfsgifO93CgiKiZfNmz40XEB6LKaxLj+dA4 rkwAlL+suO2rOQD0RyIyNuHfljOpmFJ2a9DBCvBTQgYbqOK7ehE2TzlT2I+rHppIcAZFWQR8+iIHX TNUwKw4Lo+KtQIXQEacs9v7JZTXAAaZYQkNKsEU4/ZTkpw5mE+/12rD+PkDuEWTPrPjO2vQyHl94M w5aUa2L4bLvHFAFky6bQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCgLC-001CBX-RS; Tue, 03 Jan 2023 12:24:26 +0000 Received: from ns1.kot-begemot.co.uk ([217.160.28.25] helo=www.kot-begemot.co.uk) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1pCf43-000sWN-D5 for linux-um@lists.infradead.org; Tue, 03 Jan 2023 11:02:42 +0000 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: X-Clacks-Overhead: GNU Terry Pratchett X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230103_030239_754007_5FBAC2AE X-CRM114-Status: GOOD ( 22.81 ) X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-um" Errors-To: linux-um-bounces+linux-um=archiver.kernel.org@lists.infradead.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/ _______________________________________________ linux-um mailing list linux-um@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-um