Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp1447387lqj; Tue, 4 Jun 2024 01:35:49 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX0PHUp76iCu40GiUH4ddnF/eIujQkJvqVRlwfAhGzNMOrGhzDwWook7ALDOt/vsl/lpfVzuDf2pvrgqcpggh8IBs6lRRWwfD2FlHk0Gw== X-Google-Smtp-Source: AGHT+IFaoxQ5ElCJxxHJ0eQVDJiEQ2Fln6N+w41y+LKSKRIjinL3v4nMhv/53vL665cnaz1TxS4G X-Received: by 2002:a05:6358:80a1:b0:199:3fed:7c6b with SMTP id e5c5f4694b2df-19b48d4d4b2mr1545143955d.2.1717490149198; Tue, 04 Jun 2024 01:35:49 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717490149; cv=pass; d=google.com; s=arc-20160816; b=jA3dvv5JVgCHaK/vLGRXhfezDcND8nq5wNuTrXmh3C1KPFG3F36BKRAU188ZRKev9H OmxndtpuJAsmSU5sotwGIn8Kz0Zgf7Rx9spOBGpaDl1MN7BnJWtK0MQi7AVNY0YoKq3/ bur8o0ylof6PLT2J8JdnJsm+kXMiY4uqgSWP2TXznyxTAtuK2p44XVNeT3GjAmWc0987 Epj+Im4+W5v674fkfBk6porLhn1UJT3jVZkYAzcYTV6jfteVqLfldDe6exZW7xewnGca WiPQHp7xVdlQ74lMyGmIoxKsYPtCNLej5P1wM1PxKPDox7wzPTJgP2kRPXi8Yp1u1pQY tllw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=vlJFBF+2F9amzZl23Um70l3BW0w6x+XOMeye4BFUQXc=; fh=KXQ4B4zpu00sSzIPRDnlTOeDHjaQjBwIhWldfQxz5LI=; b=lrnb7t8prw66tU2OhKI8SYf8qGo2JlCZuGXuux88DfO2xjLP8aEJeZWsZceZfq3Rod pZKLk+acK2Ad8IFXHOdMFG4VulTBMxwpeS21onrXqg1XMBvf85EJylRcnpB3cPiGSgdm SccSAZzpfPWlpGkt5GSmCuZU2Bz1Vl/iEJ3sDWhquI0042B/cYSzGX57l7W+sWkkB5g4 MnP6qqIrzCn/DLZgpK3a/Sw8k9ElfLy2RI/8I00ExC2w9h78AxaDUMUdaHaorGKxV1SS 47yCZfJy8l6dF0X8osciZ7pPEmukB/ETdzBY+LvmSPWx5E7QxlZ1ngoTcs9L6mJOhnpy 1/Ew==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=djjIM4qP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id 41be03b00d2f7-6c359e09a40si8004021a12.250.2024.06.04.01.35.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 01:35:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-200252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=djjIM4qP; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-200252-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-200252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 900EBB2140F for ; Tue, 4 Jun 2024 08:32:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 072D914290A; Tue, 4 Jun 2024 08:32:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="djjIM4qP" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 19C8F3EA69; Tue, 4 Jun 2024 08:32:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717489931; cv=none; b=IYDYws4hTtQ1gRSBKzVdkD7wN3P8xuxKsrZK9tBuI7Qfm1cLYufDkKEzlwa2x2VbPx4JPQhbXa/bPmbB0TAU8ZYhY2KbaRn5RX9VGmPLETwaYgijK3NDEfRIRBa/NHyd3mbwsVa/OyO3Sy9jU3PEC90pI9vNxavT3y7ABNx/zwQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717489931; c=relaxed/simple; bh=TudwJC2mySdD/07ev8fN3GTUmSReWRPtzu1meagMp/4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ezgiTb7Luq2jRl3UTmK6AWnLY64VjzmZvZ9dHOMRD0hZIevjIdwcQaW0oq9NasRmVd/QvNLvMG7VUCTKW2M0vxKbVM1fSL8NxagC/V0gKwKhYNbOkYXRCFqmziXqUgTxciWfRcCUhcqEHQ7dMC1D8RAZX8B8B4f1rsC0cTdiOJ0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=djjIM4qP; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03605C2BBFC; Tue, 4 Jun 2024 08:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1717489930; bh=TudwJC2mySdD/07ev8fN3GTUmSReWRPtzu1meagMp/4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=djjIM4qPJVvrJG/3oJFJKYFcNfV4LBHhTfXOXQTK9uWabNERAkHOiFGl7aB3GTDKh H7dtfSszw4s3g0rwbaup+mGPZbxOktbd2DCOlNQmX5iOqFyZ6pDT0D0gDd3Uzt7kD4 H8EIcZtNOj1saTPyh6yDdBPTVF1PC0aDCoQpICV5YHgm9vKlAiOsgyI/tycdgQ6Wzn e5shvqY+wz7nAmETFN4jX84LdPbmXWXbly5bmhCI1yN+mEoUz1BZeSaTl2sKWHLoQJ so68vwEQAAdK2f88icoWLLl9xICHJwchQwEx1B3F/GNs9PSNTI/Tv728K8QNKY+dlg RY/T3BIzfCXZQ== Date: Tue, 4 Jun 2024 11:32:05 +0300 From: Leon Romanovsky To: Shradha Gupta Cc: linux-hardening@vger.kernel.org, netdev@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, Colin Ian King , Ahmed Zaki , Pavan Chebbi , Souradeep Chakrabarti , Konstantin Taranov , Kees Cook , Paolo Abeni , Jakub Kicinski , Eric Dumazet , "David S. Miller" , Dexuan Cui , Wei Liu , Haiyang Zhang , "K. Y. Srinivasan" , Jason Gunthorpe , Long Li , Shradha Gupta Subject: Re: [PATCH net-next v3] net: mana: Allow variable size indirection table Message-ID: <20240604083205.GM3884@unreal> References: <1717169861-15825-1-git-send-email-shradhagupta@linux.microsoft.com> <20240603084122.GK3884@unreal> <20240604053648.GA14220@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240604053648.GA14220@linuxonhyperv3.guj3yctzbm1etfxqx2vob5hsef.xx.internal.cloudapp.net> On Mon, Jun 03, 2024 at 10:36:48PM -0700, Shradha Gupta wrote: > On Mon, Jun 03, 2024 at 11:41:22AM +0300, Leon Romanovsky wrote: > > On Fri, May 31, 2024 at 08:37:41AM -0700, Shradha Gupta wrote: > > > Allow variable size indirection table allocation in MANA instead > > > of using a constant value MANA_INDIRECT_TABLE_SIZE. > > > The size is now derived from the MANA_QUERY_VPORT_CONFIG and the > > > indirection table is allocated dynamically. > > > > > > Signed-off-by: Shradha Gupta > > > Reviewed-by: Dexuan Cui > > > Reviewed-by: Haiyang Zhang > > > --- > > > Changes in v3: > > > * Fixed the memory leak(save_table) in mana_set_rxfh() > > > > > > Changes in v2: > > > * Rebased to latest net-next tree > > > * Rearranged cleanup code in mana_probe_port to avoid extra operations > > > --- > > > drivers/infiniband/hw/mana/qp.c | 10 +-- > > > drivers/net/ethernet/microsoft/mana/mana_en.c | 68 ++++++++++++++++--- > > > .../ethernet/microsoft/mana/mana_ethtool.c | 27 +++++--- > > > include/net/mana/gdma.h | 4 +- > > > include/net/mana/mana.h | 9 +-- > > > 5 files changed, 89 insertions(+), 29 deletions(-) > > > > <...> > > > > > +free_indir: > > > + apc->indir_table_sz = 0; > > > + kfree(apc->indir_table); > > > + apc->indir_table = NULL; > > > + kfree(apc->rxobj_table); > > > + apc->rxobj_table = NULL; > > > reset_apc: > > > kfree(apc->rxqs); > > > apc->rxqs = NULL; > > > @@ -2897,6 +2936,7 @@ void mana_remove(struct gdma_dev *gd, bool suspending) > > > { > > > > <...> > > > > > @@ -2931,6 +2972,11 @@ void mana_remove(struct gdma_dev *gd, bool suspending) > > > } > > > > > > unregister_netdevice(ndev); > > > + apc->indir_table_sz = 0; > > > + kfree(apc->indir_table); > > > + apc->indir_table = NULL; > > > + kfree(apc->rxobj_table); > > > + apc->rxobj_table = NULL; > > > > Why do you need to NULLify here? Will apc is going to be accessible > > after call to mana_remove? or port probe failure? > Right, they won't be accessed. This is just for the sake of completeness > and to prevent double free in case there are code bug in other place. This coding patter is called defensive programming, which is discouraged in the kernel. You are not preventing double free, but hiding bugs which were possible to be found by various static analysis tools. Please don't do it. Thanks > > Regards, > Shradha. > > > > Thanks