Loading drivers/char/diag/diagfwd_socket.c +24 −28 Original line number Diff line number Diff line Loading @@ -576,10 +576,16 @@ static void socket_read_work_fn(struct work_struct *work) struct diag_socket_info, read_work); if (!info || !info->hdl) if (!info) return; mutex_lock(&info->socket_info_mutex); if (!info->hdl || !info->hdl->sk) { mutex_unlock(&info->socket_info_mutex); return; } err = sock_error(info->hdl->sk); mutex_unlock(&info->socket_info_mutex); if (unlikely(err == -ENETRESET)) { socket_close_channel(info); if (info->port_type == PORT_TYPE_SERVER) Loading Loading @@ -721,7 +727,6 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) read_msg.msg_name = &src_addr; read_msg.msg_namelen = sizeof(src_addr); if (info->port_type != PORT_TYPE_SERVER) { mutex_lock(&info->socket_info_mutex); if (!info->hdl) { DIAG_LOG(DIAG_DEBUG_PERIPHERALS, Loading @@ -730,18 +735,15 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) mutex_unlock(&info->socket_info_mutex); goto fail; } } err = kernel_sock_ioctl(info->hdl, TIOCINQ, (unsigned long)&pkt_len); if (err || pkt_len < 0) { if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); break; } if (pkt_len > bytes_remaining) { buf_full = 1; if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); break; } Loading @@ -752,7 +754,6 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) read_len = kernel_recvmsg(info->hdl, &read_msg, &iov, 1, pkt_len, MSG_DONTWAIT); if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); if (unlikely(read_len == -ENETRESET)) { mutex_lock(channel_mutex); Loading Loading @@ -861,15 +862,12 @@ static int diag_socket_write(void *ctxt, unsigned char *buf, int len) write_msg.msg_name = &info->remote_addr; write_msg.msg_namelen = sizeof(info->remote_addr); write_msg.msg_flags |= MSG_DONTWAIT; if (info->port_type != PORT_TYPE_SERVER) { mutex_lock(&info->socket_info_mutex); if (!info->hdl) { mutex_unlock(&info->socket_info_mutex); return -ENODEV; } } write_len = kernel_sendmsg(info->hdl, &write_msg, &iov, 1, len); if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); if (write_len < 0) { err = write_len; Loading Loading @@ -968,7 +966,6 @@ static void __diag_socket_init(struct diag_socket_info *info) break; } if (info->port_type == PORT_TYPE_CLIENT) mutex_init(&info->socket_info_mutex); info->svc_id = DIAG_SVC_ID; info->ins_id = ins_base + ins_offset; Loading Loading @@ -1127,7 +1124,6 @@ static void __diag_socket_exit(struct diag_socket_info *info) if (info->hdl) sock_release(info->hdl); info->hdl = NULL; if (info->port_type == PORT_TYPE_CLIENT) mutex_destroy(&info->socket_info_mutex); if (info->wq) destroy_workqueue(info->wq); Loading Loading
drivers/char/diag/diagfwd_socket.c +24 −28 Original line number Diff line number Diff line Loading @@ -576,10 +576,16 @@ static void socket_read_work_fn(struct work_struct *work) struct diag_socket_info, read_work); if (!info || !info->hdl) if (!info) return; mutex_lock(&info->socket_info_mutex); if (!info->hdl || !info->hdl->sk) { mutex_unlock(&info->socket_info_mutex); return; } err = sock_error(info->hdl->sk); mutex_unlock(&info->socket_info_mutex); if (unlikely(err == -ENETRESET)) { socket_close_channel(info); if (info->port_type == PORT_TYPE_SERVER) Loading Loading @@ -721,7 +727,6 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) read_msg.msg_name = &src_addr; read_msg.msg_namelen = sizeof(src_addr); if (info->port_type != PORT_TYPE_SERVER) { mutex_lock(&info->socket_info_mutex); if (!info->hdl) { DIAG_LOG(DIAG_DEBUG_PERIPHERALS, Loading @@ -730,18 +735,15 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) mutex_unlock(&info->socket_info_mutex); goto fail; } } err = kernel_sock_ioctl(info->hdl, TIOCINQ, (unsigned long)&pkt_len); if (err || pkt_len < 0) { if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); break; } if (pkt_len > bytes_remaining) { buf_full = 1; if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); break; } Loading @@ -752,7 +754,6 @@ static int diag_socket_read(void *ctxt, unsigned char *buf, int buf_len) read_len = kernel_recvmsg(info->hdl, &read_msg, &iov, 1, pkt_len, MSG_DONTWAIT); if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); if (unlikely(read_len == -ENETRESET)) { mutex_lock(channel_mutex); Loading Loading @@ -861,15 +862,12 @@ static int diag_socket_write(void *ctxt, unsigned char *buf, int len) write_msg.msg_name = &info->remote_addr; write_msg.msg_namelen = sizeof(info->remote_addr); write_msg.msg_flags |= MSG_DONTWAIT; if (info->port_type != PORT_TYPE_SERVER) { mutex_lock(&info->socket_info_mutex); if (!info->hdl) { mutex_unlock(&info->socket_info_mutex); return -ENODEV; } } write_len = kernel_sendmsg(info->hdl, &write_msg, &iov, 1, len); if (info->port_type != PORT_TYPE_SERVER) mutex_unlock(&info->socket_info_mutex); if (write_len < 0) { err = write_len; Loading Loading @@ -968,7 +966,6 @@ static void __diag_socket_init(struct diag_socket_info *info) break; } if (info->port_type == PORT_TYPE_CLIENT) mutex_init(&info->socket_info_mutex); info->svc_id = DIAG_SVC_ID; info->ins_id = ins_base + ins_offset; Loading Loading @@ -1127,7 +1124,6 @@ static void __diag_socket_exit(struct diag_socket_info *info) if (info->hdl) sock_release(info->hdl); info->hdl = NULL; if (info->port_type == PORT_TYPE_CLIENT) mutex_destroy(&info->socket_info_mutex); if (info->wq) destroy_workqueue(info->wq); Loading