Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1897308pxb; Thu, 7 Oct 2021 18:10:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzxCt4g2ujSY+qZw3o+dKt7tyOoXKCzwl7PQcebbAqcX5I/ux0lpe03MquAw95PhScGNqEo X-Received: by 2002:a05:6402:1157:: with SMTP id g23mr11226706edw.379.1633655404372; Thu, 07 Oct 2021 18:10:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633655404; cv=none; d=google.com; s=arc-20160816; b=XyMvPKUve7LCBpdpF2iuK9CkkWNsNTHTvW/HHAWUBnFa1hDsG0Hxi4UQ5xRdE3XBek NBxaKM3cNhWOiSspSHhIQrfDTdleFiav/iU1BJqqXDAuajB3Y11xacx3h9nUgTKx2loZ /Re9syFuy7qufxDsA5JArl6MPB+A1b6+wA5JeVWeRiWiPc2JSCdQY6S4pPwkLhPUnapQ SYsxX+LC/tUyVq3fBAzckx4jHms2Vu+LZawdxQltEumUuyCdnrTf6lwJ4O7jGYRcYD1S DwPjtqUkwrIVbNG92yUDuDlsLO519z+dMR77aIlu+Kzw508Q8WByuvX9TiKSkY3N929c Y3jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=QU+Moeggewl1XctjHAmgtpUCjZDtVr5OdCUxyLf0ZNE=; b=jzPY4uwel9n6AI+7CEDV5DCoHEMFqWZ8AV6B+FB6lqMkfw7+Ux/hLBTlOAvsh/KEVg kFWq5JVc6Wl047lgYeE0oXaUZtY+GxxgbeN9GkuOey902J+ltE+19CDYl34ityK5AXDk lEmGLp2fxrpo05/7UZgBqrtmS/wDcpN5KlkNlCa6ASTbtNNVIEQ2YOZsgopoAfAaVc62 uYsNx2ak7w7gbn6CAYKjXfRLR1Wol0O7yXstvaDQRXDG/jCCKVgCK/KIm8Ll+pxzf1qJ 8Y/OrOSP1KSRwMO6D3BJ4vdM9yBm8LGQ6mdqIWWgPKf/aMq1F6MEDR2jMym7gBcZh0aO WDqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tDeRF1qE; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cc12si1258247edb.194.2021.10.07.18.09.40; Thu, 07 Oct 2021 18:10:04 -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=@kernel.org header.s=k20201202 header.b=tDeRF1qE; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234338AbhJHAqs (ORCPT + 99 others); Thu, 7 Oct 2021 20:46:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:53052 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229487AbhJHAqr (ORCPT ); Thu, 7 Oct 2021 20:46:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 12D3A61056; Fri, 8 Oct 2021 00:44:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633653892; bh=3Nq6CakiX02/jiCPVuoYRZGiZcNauO7mQNhGl4vQgNA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tDeRF1qEnthEbVTxHG0t/sK+HKOtE0Fi7Nm6p0lRSVE4URBRZO/E32Y9+qtAslNo5 sUbsLuZWp5y87qDQ6jTRbZTeroVkHMeXoRDWVIYI4spC48JoE7sfg6SvvX27QxfAXO oBeGJ60rRYEOf9QFeO48rFW/0qVNmZ6mK3apXgPZ2AenwJTg18648sq/YDcbdvTNCV SPRX/g2SAjFGQqbOy/CsS+bpul7u/ACoTMx3TtDvp3W+so74SsEOOclnhJlzi061RQ Pu5Gq0FT5fkVBKH7wWHhBuzC0gu7b+njVP4aox7k5SZG9nj/xhsH382A5jFnruCoE6 WjWouylgRMj+Q== Date: Fri, 8 Oct 2021 03:44:48 +0300 From: Leon Romanovsky To: Steven Rostedt Cc: "David S . Miller" , Jakub Kicinski , Ido Schimmel , Ingo Molnar , Jiri Pirko , linux-kernel@vger.kernel.org, linux-rdma@vger.kernel.org, mlxsw@nvidia.com, Moshe Shemesh , netdev@vger.kernel.org, Saeed Mahameed , Salil Mehta , Shay Drory , Tariq Toukan , Yisen Zhuang Subject: Re: [PATCH net-next v3 1/5] devlink: Reduce struct devlink exposure Message-ID: References: <39692583a2aace1b9e435399344f097c72073522.1633589385.git.leonro@nvidia.com> <20211007155800.1ff26948@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211007155800.1ff26948@gandalf.local.home> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 03:58:00PM -0400, Steven Rostedt wrote: > On Thu, 7 Oct 2021 09:55:15 +0300 > Leon Romanovsky wrote: > > > +void *devlink_priv(struct devlink *devlink) > > +{ > > + BUG_ON(!devlink); > > Do we really want to bring down the kernel in this case? It was before. > > Can't we just have: > > if (WARN_ON(!devlink)) > return NULL; > ? Callers of devlink_priv() are not prepared to have NULL here, they don't check return value at all,and this BUG_ON() can't happen at all. > > Same for the below as well. I can send followup patch. Thanks > > -- Steve > > > + return &devlink->priv; > > +} > > +EXPORT_SYMBOL_GPL(devlink_priv); > > + > > +struct devlink *priv_to_devlink(void *priv) > > +{ > > + BUG_ON(!priv); > > + return container_of(priv, struct devlink, priv); > > +} > > +EXPORT_SYMBOL_GPL(priv_to_devlink); > > + > > +struct device *devlink_to_dev(const struct devlink *devlink) > > +{ > > + return devlink->dev; > > +} > > +EXPORT_SYMBOL_GPL(devlink_to_dev); > > +