lkml.org 
[lkml]   [2021]   [Oct]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next v3 1/5] devlink: Reduce struct devlink exposure
On Thu, Oct 07, 2021 at 03:58:00PM -0400, Steven Rostedt wrote:
> On Thu, 7 Oct 2021 09:55:15 +0300
> Leon Romanovsky <leon@kernel.org> 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);
> > +

\
 
 \ /
  Last update: 2021-10-08 02:45    [W:0.043 / U:0.072 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site