From: patchwork-bot+netdevbpf@kernel.org
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: vladimir.oltean@nxp.com, claudiu.manoil@nxp.com,
alexandre.belloni@bootlin.com, UNGLinuxDriver@microchip.com,
davem@davemloft.net, kuba@kernel.org, f.fainelli@gmail.com,
netdev@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net-next] net: mscc: ocelot: fix error handling bugs in mscc_ocelot_init_ports()
Date: Thu, 04 Feb 2021 01:30:07 +0000 [thread overview]
Message-ID: <161240220714.12107.14490522702137689689.git-patchwork-notify@kernel.org> (raw)
In-Reply-To: <YBkXhqRxHtRGzSnJ@mwanda>
Hello:
This series was applied to netdev/net-next.git (refs/heads/master):
On Tue, 2 Feb 2021 12:12:38 +0300 you wrote:
> There are several error handling bugs in mscc_ocelot_init_ports(). I
> went through the code, and carefully audited it and made fixes and
> cleanups.
>
> 1) The ocelot_probe_port() function didn't have a mirror release function
> so it was hard to follow. I created the ocelot_release_port()
> function.
> 2) In the ocelot_probe_port() function, if the register_netdev() call
> failed, then it lead to a double free_netdev(dev) bug. Fix this by
> setting "ocelot->ports[port] = NULL" on the error path.
> 3) I was concerned that the "port" which comes from of_property_read_u32()
> might be out of bounds so I added a check for that.
> 4) In the original code if ocelot_regmap_init() failed then the driver
> tried to continue but I think that should be a fatal error.
> 5) If ocelot_probe_port() failed then the most recent devlink was leaked.
> The fix for mostly came Vladimir Oltean. Get rid of "registered_ports"
> and just set a bit in "devlink_ports_registered" to say when the
> devlink port has been registered (and needs to be unregistered on
> error). There are fewer than 32 ports so a u32 is large enough for
> this purpose.
> 6) The error handling if the final ocelot_port_devlink_init() failed had
> two problems. The "while (port-- >= 0)" loop should have been
> "--port" pre-op instead of a post-op to avoid a buffer underflow.
> The "if (!registered_ports[port])" condition was reversed leading to
> resource leaks and double frees.
>
> [...]
Here is the summary with links:
- [net-next] net: mscc: ocelot: fix error handling bugs in mscc_ocelot_init_ports()
https://git.kernel.org/netdev/net-next/c/e0c16233577f
- [v3,2/2,net-next] net: mscc: ocelot: fix error code in mscc_ocelot_probe()
https://git.kernel.org/netdev/net-next/c/4160d9ec5b41
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
prev parent reply other threads:[~2021-02-04 1:31 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-02-02 9:12 [PATCH net-next] net: mscc: ocelot: fix error handling bugs in mscc_ocelot_init_ports() Dan Carpenter
2021-02-02 9:13 ` [PATCH v3 2/2 net-next] net: mscc: ocelot: fix error code in mscc_ocelot_probe() Dan Carpenter
2021-02-04 1:30 ` patchwork-bot+netdevbpf [this message]
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=161240220714.12107.14490522702137689689.git-patchwork-notify@kernel.org \
--to=patchwork-bot+netdevbpf@kernel.org \
--cc=UNGLinuxDriver@microchip.com \
--cc=alexandre.belloni@bootlin.com \
--cc=claudiu.manoil@nxp.com \
--cc=dan.carpenter@oracle.com \
--cc=davem@davemloft.net \
--cc=f.fainelli@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=vladimir.oltean@nxp.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