chelsio/chtls: Fix panic when listen on multiadapter

Add the logic to compare net_device returned by ip_dev_find()
with the net_device list in cdev->ports[] array and return
net_device if matched else NULL.

Fixes: 6abde0b241 ("crypto/chtls: IPv6 support for inline TLS")
Signed-off-by: Venkatesh Ellapu <venkatesh.e@chelsio.com>
Signed-off-by: Vinay Kumar Yadav <vinay.yadav@chelsio.com>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Vinay Kumar Yadav 2020-10-19 17:20:23 +05:30 committed by Jakub Kicinski
parent 86cdf9ca44
commit 9819f22c41

View File

@ -92,11 +92,13 @@ static void chtls_sock_release(struct kref *ref)
static struct net_device *chtls_find_netdev(struct chtls_dev *cdev, static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
struct sock *sk) struct sock *sk)
{ {
struct adapter *adap = pci_get_drvdata(cdev->pdev);
struct net_device *ndev = cdev->ports[0]; struct net_device *ndev = cdev->ports[0];
#if IS_ENABLED(CONFIG_IPV6) #if IS_ENABLED(CONFIG_IPV6)
struct net_device *temp; struct net_device *temp;
int addr_type; int addr_type;
#endif #endif
int i;
switch (sk->sk_family) { switch (sk->sk_family) {
case PF_INET: case PF_INET:
@ -127,8 +129,12 @@ static struct net_device *chtls_find_netdev(struct chtls_dev *cdev,
return NULL; return NULL;
if (is_vlan_dev(ndev)) if (is_vlan_dev(ndev))
return vlan_dev_real_dev(ndev); ndev = vlan_dev_real_dev(ndev);
return ndev;
for_each_port(adap, i)
if (cdev->ports[i] == ndev)
return ndev;
return NULL;
} }
static void assign_rxopt(struct sock *sk, unsigned int opt) static void assign_rxopt(struct sock *sk, unsigned int opt)