diff mbox series

[RFC,v2,net-next,3/8] net: dsa: ocelot: felix: NULL check on variable

Message ID 20210710192602.2186370-4-colin.foster@in-advantage.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series Add support for VSC7511-7514 chips over SPI | expand

Checks

Context Check Description
netdev/cover_letter success Link
netdev/fixes_present success Link
netdev/patch_count success Link
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 1 maintainers not CCed: vladimir.oltean@nxp.com
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Colin Foster July 10, 2021, 7:25 p.m. UTC
Add NULL check before dereferencing array

Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
---
 drivers/net/dsa/ocelot/felix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Vladimir Oltean July 10, 2021, 8:06 p.m. UTC | #1
On Sat, Jul 10, 2021 at 12:25:57PM -0700, Colin Foster wrote:
> Add NULL check before dereferencing array
> 
> Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> ---

The patch is correct but is insufficiently documented. In particular,
people might interpret it as a bug fix and backport it to stable
kernels.
Colin Foster July 11, 2021, 4:47 p.m. UTC | #2
On Sat, Jul 10, 2021 at 11:06:28PM +0300, Vladimir Oltean wrote:
> On Sat, Jul 10, 2021 at 12:25:57PM -0700, Colin Foster wrote:
> > Add NULL check before dereferencing array
> > 
> > Signed-off-by: Colin Foster <colin.foster@in-advantage.com>
> > ---
> 
> The patch is correct but is insufficiently documented. In particular,
> people might interpret it as a bug fix and backport it to stable
> kernels.

That makes sense. I'll clarify that it is only something that'll affect
future drivers and not a bug fix.
diff mbox series

Patch

diff --git a/drivers/net/dsa/ocelot/felix.c b/drivers/net/dsa/ocelot/felix.c
index ce607fbaaa3a..74ae322b2126 100644
--- a/drivers/net/dsa/ocelot/felix.c
+++ b/drivers/net/dsa/ocelot/felix.c
@@ -852,7 +852,7 @@  static void felix_phylink_mac_config(struct dsa_switch *ds, int port,
 	struct felix *felix = ocelot_to_felix(ocelot);
 	struct dsa_port *dp = dsa_to_port(ds, port);
 
-	if (felix->pcs[port])
+	if (felix->pcs && felix->pcs[port])
 		phylink_set_pcs(dp->pl, &felix->pcs[port]->pcs);
 }