Skip to content

Commit fe13cb2

Browse files
committed
ksmbd: fix
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
1 parent 8b9c3ec commit fe13cb2

File tree

2 files changed

+20
-23
lines changed

2 files changed

+20
-23
lines changed

transport_tcp.c

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,14 @@ static int create_socket(struct interface *iface)
544544
return ret;
545545
}
546546

547-
bool ksmbd_find_netdev_name_iface_list(char *netdev_name)
547+
struct interface *ksmbd_find_netdev_name_iface_list(char *netdev_name)
548548
{
549549
struct interface *iface;
550550

551551
list_for_each_entry(iface, &iface_list, entry)
552552
if (!strcmp(iface->name, netdev_name))
553-
return true;
554-
return false;
553+
return iface;
554+
return NULL;
555555
}
556556

557557
static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
@@ -560,22 +560,21 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
560560
struct net_device *netdev = netdev_notifier_info_to_dev(ptr);
561561
struct interface *iface;
562562
int ret;
563-
bool found = false;
564563

565564
switch (event) {
566565
case NETDEV_UP:
567566
if (netdev->priv_flags & IFF_BRIDGE_PORT)
568567
return NOTIFY_OK;
569568

570-
found = ksmbd_find_netdev_name_iface_list(netdev->name);
571-
if (found == true && iface->state == IFACE_STATE_DOWN) {
569+
iface = ksmbd_find_netdev_name_iface_list(netdev->name);
570+
if (iface && iface->state == IFACE_STATE_DOWN) {
572571
ksmbd_debug(CONN, "netdev-up event: netdev(%s) is going up\n",
573572
iface->name);
574573
ret = create_socket(iface);
575574
if (ret)
576575
return NOTIFY_OK;
577576
}
578-
if (found == false && bind_additional_ifaces) {
577+
if (!iface && bind_additional_ifaces) {
579578
iface = alloc_iface(kstrdup(netdev->name, KSMBD_DEFAULT_GFP));
580579
if (!iface)
581580
return NOTIFY_OK;
@@ -587,21 +586,19 @@ static int ksmbd_netdev_event(struct notifier_block *nb, unsigned long event,
587586
}
588587
break;
589588
case NETDEV_DOWN:
590-
list_for_each_entry(iface, &iface_list, entry) {
591-
if (!strcmp(iface->name, netdev->name) &&
592-
iface->state == IFACE_STATE_CONFIGURED) {
593-
ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n",
594-
iface->name);
595-
tcp_stop_kthread(iface->ksmbd_kthread);
596-
iface->ksmbd_kthread = NULL;
597-
mutex_lock(&iface->sock_release_lock);
598-
tcp_destroy_socket(iface->ksmbd_socket);
599-
iface->ksmbd_socket = NULL;
600-
mutex_unlock(&iface->sock_release_lock);
601-
602-
iface->state = IFACE_STATE_DOWN;
603-
break;
604-
}
589+
iface = ksmbd_find_netdev_name_iface_list(netdev->name);
590+
if (iface && iface->state == IFACE_STATE_CONFIGURED) {
591+
ksmbd_debug(CONN, "netdev-down event: netdev(%s) is going down\n",
592+
iface->name);
593+
tcp_stop_kthread(iface->ksmbd_kthread);
594+
iface->ksmbd_kthread = NULL;
595+
mutex_lock(&iface->sock_release_lock);
596+
tcp_destroy_socket(iface->ksmbd_socket);
597+
iface->ksmbd_socket = NULL;
598+
mutex_unlock(&iface->sock_release_lock);
599+
600+
iface->state = IFACE_STATE_DOWN;
601+
break;
605602
}
606603
break;
607604
}

transport_tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#define __KSMBD_TRANSPORT_TCP_H__
88

99
int ksmbd_tcp_set_interfaces(char *ifc_list, int ifc_list_sz);
10-
bool ksmbd_find_netdev_name_iface_list(char *netdev_name);
10+
struct interface *ksmbd_find_netdev_name_iface_list(char *netdev_name);
1111
int ksmbd_tcp_init(void);
1212
void ksmbd_tcp_destroy(void);
1313

0 commit comments

Comments
 (0)