Received: by 10.213.65.16 with SMTP id m16csp2540imf; Sun, 11 Mar 2018 11:44:23 -0700 (PDT) X-Google-Smtp-Source: AG47ELsFHCgqMKpoJfwMc/E7itQ4hJnRs+/P9bM+ychRJp5lXzCVarukJTv8aojfcAdxJXhoLE/Q X-Received: by 2002:a17:902:bc04:: with SMTP id n4-v6mr2387113pls.97.1520793863199; Sun, 11 Mar 2018 11:44:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520793863; cv=none; d=google.com; s=arc-20160816; b=AGz2ewEpuG3alHvSzoYBE4BsD+0daSS4NEr3RMi+gA4KFftmvIXzcOl99ef9rTGUgB vdtGSzU2LXqa+WLoXD/fmEvleCwMP/SglxzG1/yehlsORMRGHcPECfiUtXlPtBtTbDxG jNr2y+ZCcSQZOWW72Coy8sM6v4kowVZdpNf+ihd3eI9k0glSleWGHF354GDKklcXrFim 5bnixaGDT1i5X7nydb+Nfd6anrfkYMmne9VJEFtrsSUIA1w/nO6ukjGyMMwT6SQqmraH kvnwQsnHWqoWTGp12XAQWCCr3RDfejgpayuqFoxbRyZ4Ni4IYrwTBrLZUlfJty0V9HDi hdBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=rLieXjLLuGZsLjXycmvUFqlQd5veG6angOGCTJMJD+Y=; b=Z0pSNNUw/Yp6hAEu/+DzGvnf5F98e1yVtu4oJwgxF+B4hyywRm/UNOSF6NIzUvP4eK Z7Q01/QM+3YuF3h6e9Fz20/V7nndUOZAdck01HYsLoEBq3XAYYlNmZBHkhOWHiMSvy5M p1lRuiEU9UsG1NEF4MHBo5MSjCV5nAB/iLF0TdXqpXz2UHTpFde+Q8wJqkSPbARrvuid olqKrnCt4bDk4kyBFeIDL4wCkWk0+4NX97AVDN5SwW+poDCBW7EQ2PjiL3hFulXBAWb/ pC46eiEHgd/l6EIbqX9sX8+szsH9UN5e1MuQE9xVmTtid1cUxpELUuIEJUyQ50xDlJ56 WW2w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j3si3869124pfb.288.2018.03.11.11.43.57; Sun, 11 Mar 2018 11:44:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932290AbeCKSm3 (ORCPT + 99 others); Sun, 11 Mar 2018 14:42:29 -0400 Received: from ivanoab5.miniserver.com ([78.31.111.25]:44926 "EHLO www.kot-begemot.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932217AbeCKSm2 (ORCPT ); Sun, 11 Mar 2018 14:42:28 -0400 X-Greylist: delayed 2027 seconds by postgrey-1.27 at vger.kernel.org; Sun, 11 Mar 2018 14:42:27 EDT Received: from tun5.smaug.kot-begemot.co.uk ([192.168.18.6] helo=smaug.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ev5Oe-0000VY-Sg; Sun, 11 Mar 2018 18:08:36 +0000 Received: from [85.255.234.244] (helo=[192.168.43.127]) by smaug.kot-begemot.co.uk with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1ev5Oe-0008SN-8g; Sun, 11 Mar 2018 18:08:36 +0000 Subject: Re: [PATCH 1/9] um/drivers/vector_user: Delete unnecessary code in user_init_raw_fds() To: SF Markus Elfring , user-mode-linux-devel@lists.sourceforge.net, Jeff Dike , Richard Weinberger Cc: user-mode-linux-user@lists.sourceforge.net, kernel-janitors@vger.kernel.org, LKML References: From: Anton Ivanov Organization: Cambridge Greys Limited Message-ID: <33ff08e8-39cd-8558-152f-dac474fb0b5b@cambridgegreys.com> Date: Sun, 11 Mar 2018 18:08:22 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Clacks-Overhead: GNU Terry Pratchett Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks, well noted. It still does not fix it completely though. Re-reading the code it will leak a fd if the malloc for result fails. That return result; there should be inside the conditional falling back to cleanup if the alloc fails. A. On 03/11/18 15:16, SF Markus Elfring wrote: > From: Markus Elfring > Date: Sun, 11 Mar 2018 11:36:18 +0100 > > * One condition check could never be reached with a non-null pointer > at the end of this function. Thus remove the corresponding statement. > > * Delete an initialisation for the local variable "result" > which became unnecessary with this refactoring. > > Signed-off-by: Markus Elfring > --- > arch/um/drivers/vector_user.c | 4 +--- > 1 file changed, 1 insertion(+), 3 deletions(-) > > diff --git a/arch/um/drivers/vector_user.c b/arch/um/drivers/vector_user.c > index 4291f1a5d342..d6a6207d4061 100644 > --- a/arch/um/drivers/vector_user.c > +++ b/arch/um/drivers/vector_user.c > @@ -211,7 +211,7 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec) > struct sockaddr_ll sock; > int err = -ENOMEM; > char *iface; > - struct vector_fds *result = NULL; > + struct vector_fds *result; > int optval = 1; > > > @@ -276,8 +276,6 @@ static struct vector_fds *user_init_raw_fds(struct arglist *ifspec) > os_close_file(rxfd); > if (txfd >= 0) > os_close_file(txfd); > - if (result != NULL) > - kfree(result); > return NULL; > } > -- Anton R. Ivanov Cambridge Greys Limited, England and Wales company No 10273661 http://www.cambridgegreys.com/