Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp11341pxv; Wed, 21 Jul 2021 14:04:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhq7qoIp9up2IU9BuuP59fln90W/ukjLfzKoqg1AymctRqjrytdOCLgJJmuy03h4gLX5pX X-Received: by 2002:aa7:c04e:: with SMTP id k14mr9699053edo.193.1626901463121; Wed, 21 Jul 2021 14:04:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626901463; cv=none; d=google.com; s=arc-20160816; b=qyLM3haYdanSYOEd04+FrfCUFl9z9Yi2mmkOMYJv/lVRDKERdx4hx1svzShU7PIWh3 8nTCpCuUbq7pi//zcU3+Fw+cRUsNy/D9ycYXLgVpVxujppLyl1euHf1JkSD+Nk1Gww0g mqKXiMOi3Jj3narrIULONzjqYrrwwEpkATLUYb1XAGXYNmAI5wpXS/jyXMk0lRC9Xq4p 0IUDCy68Jt9jJJOh9BZbq1pPOejApoKfk6fAsiANlW6veVYw5KJYZ36vdpT9RspNDkNR sQXIRcZUNPmZhUKZV/BjVj7nW6IqfU7x3ewEf7aoc2O34HWkd3+S2oFJGAxdUA88qrxS oxIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=RSgJZgL5+8JDLD0WocVJD8SB24xW93k7iVgT/78Sy20=; b=xMWTLhiIsI6cqGAuVxuVdx85O01BqUY27Hgh8oL2fU8I4+T6KV8kwlFjYOV0acZnkJ 5A4phNIWcBwCd+moeEYHPL84tKfeM9aLVWP3xF/eN1kjeevLoNmHBBYctmV4gPb7IUvG Ax7ffM/3Xrp1c1bdXDwh9w5T+7zNPvN8MdlEPIIj5mGJlABOE9+BO9jXl/MKfBoYEZVK qfRB0C++k5VEXkTvBepEW1SRsnQ00C1Jw8l0GPuemT1NXu3nINCsEYB5g4FbJ7GgisnD OX7/qUO30wWrbE9r7TR52XFpPA0Sfe8k+Gb9iGF4JnVa9vwp1TCOA4DPO23lKEtUqNVt PDWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@pensando.io header.s=google header.b=Bz5Hdzvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s22si27316333ejx.34.2021.07.21.14.04.00; Wed, 21 Jul 2021 14:04:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@pensando.io header.s=google header.b=Bz5Hdzvh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239989AbhGUPPY (ORCPT + 99 others); Wed, 21 Jul 2021 11:15:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238315AbhGUPPX (ORCPT ); Wed, 21 Jul 2021 11:15:23 -0400 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 B4E0FC061575 for ; Wed, 21 Jul 2021 08:55:59 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id y3so1171998plp.4 for ; Wed, 21 Jul 2021 08:55:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pensando.io; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=RSgJZgL5+8JDLD0WocVJD8SB24xW93k7iVgT/78Sy20=; b=Bz5HdzvhnqAwgoTJ2mc8rFx1BZpq5k+jDTZz4jPm9R7EwU5EbHBqm+WngUGHOa3F9g LEjEORs2BZn3AT3cbgPsz5qrMl8eB58PvC/215HL1dNBAsPby8+wcsTI7Glw2+qnCXj/ VAJd4vq70yT6IOSpy3ndijUSf5ImyQ5d5Lc21BuBOgE7IdpYAVl+eI2ez6Y+/q1MGtnL qXfPTC9aQdtE7YZrgQ2SsHGl5FI+MJ0yqVm8091yvpqx+i3zRR7u6jKld9nMqwgr1rSs LpBkJ4RctuIJk3ajs08+1G8bVXdd/L0VjbhxCm9j2kYkblX2HF2eU23ovCnf60Pz5I7D CNxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=RSgJZgL5+8JDLD0WocVJD8SB24xW93k7iVgT/78Sy20=; b=IKug3Xe6w3IslQIw4ViqiR0igMFA3b7vlB+HAEbbIYGIrJHPdnRwX2VgRTe361Hnq5 CckYgeALQDYynYOjChRFlb1AC3IP7GWqL5HJgas9QwQFtCB5GsROMV/WeE+QDxMESJbp izweeddhYRcdw6DpdbbD6NpSpF/cu1mYN9R3Jnt80vXwFInxJ1sTzWYrH9TvR23nr1E+ YVQodWnP73BQXA91hM2pbMype53kta/t1Mb0sVHn3Dkoh0E5jdnqfEpbslpGICW4KkVO r8z730/EHJHRW3UqopHsm9M7u7+sENK4qyOC4zVlxqSmy8hmrWSwwX0k/CF4iV49WU7J XEkw== X-Gm-Message-State: AOAM530uV/1Ur5GigAO5b/g/gfF1YyCylGIMFW0rrn/+iEgOtqYkwtsM bxTQp317+55Jz3awtlte+luHeA== X-Received: by 2002:a17:903:3005:b029:12b:54cf:c513 with SMTP id o5-20020a1709033005b029012b54cfc513mr27997855pla.21.1626882959326; Wed, 21 Jul 2021 08:55:59 -0700 (PDT) Received: from Shannons-MacBook-Pro.local ([50.53.47.17]) by smtp.gmail.com with ESMTPSA id x3sm329098pjq.6.2021.07.21.08.55.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 21 Jul 2021 08:55:58 -0700 (PDT) Subject: Re: [PATCH net-next] ionic: cleanly release devlink instance To: Leon Romanovsky , "David S. Miller" , Jakub Kicinski Cc: Leon Romanovsky , drivers@pensando.io, linux-kernel@vger.kernel.org, Moshe Shemesh , netdev@vger.kernel.org References: <956213a5c415c30e7e9f9c20bb50bc5b50ba4d18.1626870761.git.leonro@nvidia.com> From: Shannon Nelson Message-ID: <04d36c6b-1e8d-117f-3079-8314f6b8051d@pensando.io> Date: Wed, 21 Jul 2021 08:55:56 -0700 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <956213a5c415c30e7e9f9c20bb50bc5b50ba4d18.1626870761.git.leonro@nvidia.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/21/21 5:39 AM, Leon Romanovsky wrote: > From: Leon Romanovsky > > The failure to register devlink will leave the system with dangled > devlink resource, which is not cleaned if devlink_port_register() fails. > > In order to remove access to ".registered" field of struct devlink_port, > require both devlink_register and devlink_port_register to success and > check it through device pointer. > > Fixes: fbfb8031533c ("ionic: Add hardware init and device commands") > Reviewed-by: Moshe Shemesh > Signed-off-by: Leon Romanovsky Sure, thanks. Acked-by: Shannon Nelson > --- > Future series will remove .registered field from the devlink. > --- > .../net/ethernet/pensando/ionic/ionic_devlink.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c > index b41301a5b0df..cd520e4c5522 100644 > --- a/drivers/net/ethernet/pensando/ionic/ionic_devlink.c > +++ b/drivers/net/ethernet/pensando/ionic/ionic_devlink.c > @@ -91,20 +91,20 @@ int ionic_devlink_register(struct ionic *ionic) > attrs.flavour = DEVLINK_PORT_FLAVOUR_PHYSICAL; > devlink_port_attrs_set(&ionic->dl_port, &attrs); > err = devlink_port_register(dl, &ionic->dl_port, 0); > - if (err) > + if (err) { > dev_err(ionic->dev, "devlink_port_register failed: %d\n", err); > - else > - devlink_port_type_eth_set(&ionic->dl_port, > - ionic->lif->netdev); > + devlink_unregister(dl); > + return err; > + } > > - return err; > + devlink_port_type_eth_set(&ionic->dl_port, ionic->lif->netdev); > + return 0; > } > > void ionic_devlink_unregister(struct ionic *ionic) > { > struct devlink *dl = priv_to_devlink(ionic); > > - if (ionic->dl_port.registered) > - devlink_port_unregister(&ionic->dl_port); > + devlink_port_unregister(&ionic->dl_port); > devlink_unregister(dl); > }