diff options
| author | Jakub Kicinski <kuba@kernel.org> | 2026-04-30 00:30:01 +0300 |
|---|---|---|
| committer | Jakub Kicinski <kuba@kernel.org> | 2026-05-02 02:46:30 +0300 |
| commit | fa11b40480132077de3787cf2122646b0c8ecc41 (patch) | |
| tree | 47b9eccdf29ae5ee8324b64d21b1970ec356e2e1 | |
| parent | edf4bee4215a173c0534d1851d7523d827149f9e (diff) | |
| download | linux-fa11b40480132077de3787cf2122646b0c8ecc41.tar.xz | |
net: tls: reshuffle the device ops check
We try to validate during registration that the netdev
has ops if it has features. This is currently somewhat sillily
written because we have a dereference before a NULL check
on the ops struct. Straighten this out.
No functional change intended other than saving ourselves
the very theoretical crash with a bad driver.
Note that we check earlier in the function that either ops
or TLS features are set for the device in question.
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/20260429213001.1908235-1-kuba@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
| -rw-r--r-- | net/tls/tls_device.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 99c8eff9783e..741aef09bfd3 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -1387,16 +1387,15 @@ static int tls_dev_event(struct notifier_block *this, unsigned long event, case NETDEV_FEAT_CHANGE: if (netif_is_bond_master(dev)) return NOTIFY_DONE; + if (!dev->tlsdev_ops || + !dev->tlsdev_ops->tls_dev_add || + !dev->tlsdev_ops->tls_dev_del) + return NOTIFY_BAD; if ((dev->features & NETIF_F_HW_TLS_RX) && !dev->tlsdev_ops->tls_dev_resync) return NOTIFY_BAD; - if (dev->tlsdev_ops && - dev->tlsdev_ops->tls_dev_add && - dev->tlsdev_ops->tls_dev_del) - return NOTIFY_DONE; - else - return NOTIFY_BAD; + return NOTIFY_DONE; case NETDEV_DOWN: return tls_device_down(dev); } |
