net: tls: reshuffle the device ops check
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 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.
---
CC: [email protected]
CC: [email protected]
--- net/tls/tls_device.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
net/tls/tls_device.c +5 -6
@@ -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); }
Signature · 1 line
2.54.0
Quoted 5 lines · Jakub Kicinski
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.
Quoted 7 lines
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.
Signed-off-by Jakub Kicinski <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Wed, 29 Apr 2026 14:30:01 -0700 you wrote:
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.
[...]
Here is the summary with links:
- [net-next] net: tls: reshuffle the device ops check
https://git.kernel.org/netdev/net-next/c/fa11b4048013
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html