From: Jiri Pirko <jiri@resnulli.us>
To: Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: davem@davemloft.net, mkubecek@suse.cz, andrew@lunn.ch,
f.fainelli@gmail.com, netdev@vger.kernel.org,
oss-drivers@netronome.com
Subject: Re: [PATCH net-next v3 6/6] devlink: add missing NULL checks for devlink ops
Date: Sun, 24 Feb 2019 12:03:19 +0100 [thread overview]
Message-ID: <20190224110319.GJ2759@nanopsycho.orion> (raw)
In-Reply-To: <20190222220758.7117-7-jakub.kicinski@netronome.com>
Fri, Feb 22, 2019 at 11:07:57PM CET, jakub.kicinski@netronome.com wrote:
>Commit 76726ccb7f46 ("devlink: add flash update command") and
>commit 2d8dc5bbf4e7 ("devlink: Add support for reload")
>access devlink ops without NULL-checking. Add the missing checks.
>Note that all drivers currently implementing devlink pass non-NULL
>ops, so this is not a problem.
Wouldn't it be better to rather put WARN_ON&fail when driver calls
devlink_alloc() with NULL ops and avoid these checks in the whole code?
>
>Reported-by: Florian Fainelli <f.fainelli@gmail.com>
>Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
>---
> net/core/devlink.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
>diff --git a/net/core/devlink.c b/net/core/devlink.c
>index 78c6ea1870ca..38cb0239dede 100644
>--- a/net/core/devlink.c
>+++ b/net/core/devlink.c
>@@ -2651,7 +2651,7 @@ static int devlink_nl_cmd_reload(struct sk_buff *skb, struct genl_info *info)
> struct devlink *devlink = info->user_ptr[0];
> int err;
>
>- if (!devlink->ops->reload)
>+ if (!devlink->ops || !devlink->ops->reload)
> return -EOPNOTSUPP;
>
> err = devlink_resources_validate(devlink, NULL, info);
>@@ -2669,7 +2669,7 @@ static int devlink_nl_cmd_flash_update(struct sk_buff *skb,
> const char *file_name, *component;
> struct nlattr *nla_component;
>
>- if (!devlink->ops->flash_update)
>+ if (!devlink->ops || !devlink->ops->flash_update)
> return -EOPNOTSUPP;
>
> if (!info->attrs[DEVLINK_ATTR_FLASH_UPDATE_FILE_NAME])
>--
>2.19.2
>
next prev parent reply other threads:[~2019-02-24 11:13 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-22 22:07 [PATCH net-next v3 0/6] devlink: make ethtool compat reliable Jakub Kicinski
2019-02-22 22:07 ` [PATCH net-next v3 1/6] net: devlink: turn devlink into a built-in Jakub Kicinski
2019-02-24 10:46 ` Jiri Pirko
2019-02-22 22:07 ` [PATCH net-next v3 2/6] devlink: create a special NDO for getting the devlink instance Jakub Kicinski
2019-02-24 10:51 ` Jiri Pirko
2019-02-22 22:07 ` [PATCH net-next v3 3/6] nfp: add .ndo_get_devlink Jakub Kicinski
2019-02-24 10:52 ` Jiri Pirko
2019-02-25 2:05 ` Florian Fainelli
2019-02-22 22:07 ` [PATCH net-next v3 4/6] nfp: remove ethtool flashing fallback Jakub Kicinski
2019-02-24 10:53 ` Jiri Pirko
2019-02-25 2:06 ` Florian Fainelli
2019-02-22 22:07 ` [PATCH net-next v3 5/6] devlink: hold a reference to the netdevice around ethtool compat Jakub Kicinski
2019-02-24 11:00 ` Jiri Pirko
2019-02-25 18:31 ` Jakub Kicinski
2019-02-26 3:07 ` Jakub Kicinski
2019-02-26 6:50 ` Jiri Pirko
2019-02-22 22:07 ` [PATCH net-next v3 6/6] devlink: add missing NULL checks for devlink ops Jakub Kicinski
2019-02-24 11:03 ` Jiri Pirko [this message]
2019-02-25 18:32 ` Jakub Kicinski
2019-02-26 6:50 ` Jiri Pirko
2019-02-25 1:43 ` [PATCH net-next v3 0/6] devlink: make ethtool compat reliable David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190224110319.GJ2759@nanopsycho.orion \
--to=jiri@resnulli.us \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=mkubecek@suse.cz \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@netronome.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).