Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1838772pxb; Mon, 13 Sep 2021 06:40:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7u7SGTOLrbIkWjqQ83aTmdF0ZLw5BHeVrbpJjml9zwNeMPEJ9dZYjETJ2WJdlngcgPAPH X-Received: by 2002:a05:6e02:2145:: with SMTP id d5mr7969608ilv.214.1631540431600; Mon, 13 Sep 2021 06:40:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631540431; cv=none; d=google.com; s=arc-20160816; b=LTQi0mr21f5/jsgZbxrDyjYo0exwP/QN5umL6ohQs32Ot0RP+14JW1WS/tUCOFML45 yf8FioGYDlAnKfyHYUg63uK1HJ6BAQvzXgMPhdXNOiSuzTV47ZtQeYaTaq4A7ZgkYRMn 6QW9NFOZ2VF8Y2UaVHamCh2Bf0k1AGSlbapIEFGNtfjWcOfMNVWwMBsbHVEahY+39kQ6 RM//+pKHpjh62ButcXG4p4F0EpXvAXlg9zUX6J8foxceuH4ZQpHj/mV8g3I5R8rKvNSt 9gXLEq1jZedQ/KOztFIFW8e5bwudIxyDrIh3iRKFaUYM8LXzf32Y3DyEhCstrSs4tMyC Xu3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RPe5umXNrJrcYa4XLx951PjM5xyBcmcUBJzXwVX6weo=; b=WC+2TaCKKevmMp6DzNq26sSmoI3927THjWtFRRJa2FKcruM+fO0Ew6BfkXFKCx+/eQ KseEu0Lc4jE/YcWZ4XOD+8FgCb10X41QDK4dr3gq5INn6RE5E5FGCMrIbik/XcO7rkQ8 gH7i/UnxloUsgqZ0nVIMP1lW3Muzd7kEmfMSPhjRegTg+jboRa8Rm5KxM+AvmfCaPSjl tBqV9sb3daIfO0lGpRXZgu/RPA92axonnoPnexoh8Ayhm43w7kN+1jPfm/h/VeFHpq7z 6mGFb+F+g708u9Renershpvx/l2L3n+pCs7iLZQluV8qFn/lKad+Ow+/ACD11xWGT8kd 4z7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LWPN972c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a2si6266446ilp.123.2021.09.13.06.40.17; Mon, 13 Sep 2021 06:40:31 -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=pass header.i=@linuxfoundation.org header.s=korg header.b=LWPN972c; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243826AbhIMNkG (ORCPT + 99 others); Mon, 13 Sep 2021 09:40:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:58418 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242972AbhIMNeh (ORCPT ); Mon, 13 Sep 2021 09:34:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 70E3061221; Mon, 13 Sep 2021 13:26:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631539610; bh=jnUz3WBMv0JybVg3eiXs/+qckOwE0fCjdeXvU0eza/U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LWPN972chQ0bxRE6lTVcldE6JEkyTNJ57HBjQvqsySQ/rXpYLBVBzOPT6q0f+XVUy MLL4wF8TNRBNtyBVJkm3obcmQuSKPqhrbX0jSM0TQYHO6clvD3xORGW3q1im7q70ka Adl0RqsDboL/3IZ0W5V/52W1uZXiMEsCn7FeFZUI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Moshe Shemesh , Leon Romanovsky , Shannon Nelson , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 090/236] ionic: cleanly release devlink instance Date: Mon, 13 Sep 2021 15:13:15 +0200 Message-Id: <20210913131103.411286092@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210913131100.316353015@linuxfoundation.org> References: <20210913131100.316353015@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky [ Upstream commit c2255ff47768c94a0ebc3968f007928bb47ea43b ] 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 Acked-by: Shannon Nelson Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- .../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 51d64718ed9f..3d94064c685d 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); } -- 2.30.2