Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp337967rwr; Thu, 4 May 2023 04:02:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ60vpQLZdMPhoZNV7StD5waKVpFLZtogig0mQ1AFMVFkOE6PqaFAMuulnEAd3qqeBAFIutN X-Received: by 2002:a17:903:1cd:b0:1ab:11c8:777a with SMTP id e13-20020a17090301cd00b001ab11c8777amr4324391plh.13.1683198147940; Thu, 04 May 2023 04:02:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683198147; cv=none; d=google.com; s=arc-20160816; b=yJ7RW3p0VO9rqLMWt+V2/bB9ppGczR7gvKEsw2MZwXAVmsj49hDLYw0ow5TH2icwp7 Vhr3bIPZb75nIjkqHhKwX6xW6Loy3Di2+ZpqJwzcKbc6Q0mxtdnf6hsMptQSeyTrYPSN 5zkO4ubjNaHtc/s8NrcCqp4UXPb+vnLt1L1ECtE0Xu6Y59zRXEcMPbMlXsMfAk1iFYeM zUm6pu+5xzPHPooRqBAA0ocJmp314wQFvcRk3hxI5Cw+Nj0eNilJTNP7EFyp1aie+rZh KadnQ/nlPuegZGtt8kUVLTpgKXoi8ILs2sX/tQ8pNmZ/CawU/b+kZV32PC7b+F/bdvkb qkgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=61DFu+rr/bcHzfoO+Muj5LHM6DqMfx+IQWaB1CcwUpA=; b=Ixak/uvA7XUHnElGqhAR1yQxE/8RUShWIjjjYlmg4l5n8xY6yGLmXkc0NgMHTzAW3D 8Feo9JhNNo+SUkTwlJyVILK00gpyKuD07O+NjgziIX+zpiKW2WmXHMgsbUhi0tJwMfC/ mOYBhHELt0T0HfHJHNnlFcintLwp0nxg+zR32wxvrWP+fDTvpjRBK6a8mktIbkk8xU6X SXTX7kr3PeS2NNIFlcr6LaXfyct5OglP4XOb7HJ2GPrecUnHh6gLuwWlIUwaSldTIWon N8Lo9mC02R7vOakAm9JZA4oqbjjPeJFwM/BpabCjBuAnUTfIZRyx5Qi/p4pChilUfyFP jrtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EiwI+gAS; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 25-20020a631859000000b0051b1b5917f6si33172783pgy.160.2023.05.04.04.02.11; Thu, 04 May 2023 04:02:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EiwI+gAS; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229905AbjEDK4X (ORCPT + 62 others); Thu, 4 May 2023 06:56:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230257AbjEDK4S (ORCPT ); Thu, 4 May 2023 06:56:18 -0400 Received: from mail-wm1-x32f.google.com (mail-wm1-x32f.google.com [IPv6:2a00:1450:4864:20::32f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9700349F7 for ; Thu, 4 May 2023 03:56:16 -0700 (PDT) Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-3f1e2555b5aso2595805e9.0 for ; Thu, 04 May 2023 03:56:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1683197775; x=1685789775; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=61DFu+rr/bcHzfoO+Muj5LHM6DqMfx+IQWaB1CcwUpA=; b=EiwI+gAShmb3MMDXn0XqjhPTSM/fr6HoRfKhsrH/CNynyiRL10+ad/RraXJmxz6/3r lYmLFws+VfS826dEsFhGNRp9/ZzyMmlrge8Db8Qw3iLEeqCcRNF2j8QLYkJ8LsBlI2rz d0vR+xU6HOTKUcFXY7KJ64aqGk0zlEPRjk2fR3gd4IPMpOp3UdZcaU0YdGjbP+vnlL6n PQvWB4JH41R5mrrRybwIMmVbKoJL2URvEjOlheBTvCnEtF/DyIYZnflMU/MmHEjoEDHG 8U7sVupfWz+bdv/CPIry08a9Y6OGDwsAmEXQeA6vzbeyywVxM5rWWLjVMWqgfSyX1lZc +LgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683197775; x=1685789775; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=61DFu+rr/bcHzfoO+Muj5LHM6DqMfx+IQWaB1CcwUpA=; b=jU0ZrIvVFwi0tcfu79m6A/92PS8TprS+kkzvFxKFfwtfstJSygzOWWN27bpXWdPFAP lZQkiF7yr+QvyFNNY/6XBF1tOQs+VAd5eejJCYDTErgD6xR6zZh4NqzJfLq7TPRL6mZp dZ4KYfhk7cUwsaJxoUW/Lri5HXlKAXXoC5DpHNTCT7ptBEOoMvMeWtNogbPJFgYTTgj7 nE83TqBDdf3w3102jhiFgdsw/FVZjgcB7akrfpVn4F0B5NCmLOE0b2ogwRDQnGjtDMcD kPIsimWUjzsREOUriJf9dtZwZfPnrUPvUArPW98zFsuVh5KjKOuzjS4wvfdx0JPuozHN 5YYA== X-Gm-Message-State: AC+VfDzAFPolPu7IN5C2/haumfeJM5ly0FabiXMYm8tuME4fgtjQR9kM shvE7MObweEzIHfCNYv1piXY9HYeqld1RwkdtlY= X-Received: by 2002:a1c:7209:0:b0:3f1:78d0:fc45 with SMTP id n9-20020a1c7209000000b003f178d0fc45mr16826765wmc.28.1683197775086; Thu, 04 May 2023 03:56:15 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id l2-20020a1c7902000000b003f195d540d9sm4507885wme.14.2023.05.04.03.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 May 2023 03:56:13 -0700 (PDT) Date: Thu, 4 May 2023 13:56:06 +0300 From: Dan Carpenter To: s.hauer@pengutronix.de Cc: linux-wireless@vger.kernel.org Subject: [bug report] wifi: rtw88: usb: fix priority queue to endpoint mapping Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Hello Sascha Hauer, The patch a6f187f92bcc: "wifi: rtw88: usb: fix priority queue to endpoint mapping" from Apr 17, 2023, leads to the following Smatch static checker warning: drivers/net/wireless/realtek/rtw88/usb.c:219 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[8]' drivers/net/wireless/realtek/rtw88/usb.c:220 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[9]' drivers/net/wireless/realtek/rtw88/usb.c:221 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[10]' drivers/net/wireless/realtek/rtw88/usb.c:222 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[11]' drivers/net/wireless/realtek/rtw88/usb.c:223 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[12]' drivers/net/wireless/realtek/rtw88/usb.c:224 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[13]' drivers/net/wireless/realtek/rtw88/usb.c:225 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[14]' drivers/net/wireless/realtek/rtw88/usb.c:226 rtw_usb_parse() warn: assigning (-22) to unsigned variable 'rtwusb->qsel_to_ep[15]' drivers/net/wireless/realtek/rtw88/usb.c 137 static int rtw_usb_parse(struct rtw_dev *rtwdev, 138 struct usb_interface *interface) 139 { 140 struct rtw_usb *rtwusb = rtw_get_usb_priv(rtwdev); 141 struct usb_host_interface *host_interface = &interface->altsetting[0]; 142 struct usb_interface_descriptor *interface_desc = &host_interface->desc; 143 struct usb_endpoint_descriptor *endpoint; 144 struct usb_device *usbd = interface_to_usbdev(interface); 145 int num_out_pipes = 0; 146 int i; 147 u8 num; 148 const struct rtw_chip_info *chip = rtwdev->chip; 149 const struct rtw_rqpn *rqpn; 150 151 for (i = 0; i < interface_desc->bNumEndpoints; i++) { 152 endpoint = &host_interface->endpoint[i].desc; 153 num = usb_endpoint_num(endpoint); 154 155 if (usb_endpoint_dir_in(endpoint) && 156 usb_endpoint_xfer_bulk(endpoint)) { 157 if (rtwusb->pipe_in) { 158 rtw_err(rtwdev, "IN pipes overflow\n"); 159 return -EINVAL; 160 } 161 162 rtwusb->pipe_in = num; 163 } 164 165 if (usb_endpoint_dir_in(endpoint) && 166 usb_endpoint_xfer_int(endpoint)) { 167 if (rtwusb->pipe_interrupt) { 168 rtw_err(rtwdev, "INT pipes overflow\n"); 169 return -EINVAL; 170 } 171 172 rtwusb->pipe_interrupt = num; 173 } 174 175 if (usb_endpoint_dir_out(endpoint) && 176 usb_endpoint_xfer_bulk(endpoint)) { 177 if (num_out_pipes >= ARRAY_SIZE(rtwusb->out_ep)) { 178 rtw_err(rtwdev, "OUT pipes overflow\n"); 179 return -EINVAL; 180 } 181 182 rtwusb->out_ep[num_out_pipes++] = num; 183 } 184 } 185 186 switch (usbd->speed) { 187 case USB_SPEED_LOW: 188 case USB_SPEED_FULL: 189 rtwusb->bulkout_size = RTW_USB_FULL_SPEED_BULK_SIZE; 190 break; 191 case USB_SPEED_HIGH: 192 rtwusb->bulkout_size = RTW_USB_HIGH_SPEED_BULK_SIZE; 193 break; 194 case USB_SPEED_SUPER: 195 rtwusb->bulkout_size = RTW_USB_SUPER_SPEED_BULK_SIZE; 196 break; 197 default: 198 rtw_err(rtwdev, "failed to detect usb speed\n"); 199 return -EINVAL; 200 } 201 202 rtwdev->hci.bulkout_num = num_out_pipes; 203 204 if (num_out_pipes < 1 || num_out_pipes > 4) { 205 rtw_err(rtwdev, "invalid number of endpoints %d\n", num_out_pipes); 206 return -EINVAL; 207 } 208 209 rqpn = &chip->rqpn_table[num_out_pipes]; 210 211 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID0] = dma_mapping_to_ep(rqpn->dma_map_be); 212 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID1] = dma_mapping_to_ep(rqpn->dma_map_bk); 213 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID2] = dma_mapping_to_ep(rqpn->dma_map_bk); 214 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID3] = dma_mapping_to_ep(rqpn->dma_map_be); 215 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID4] = dma_mapping_to_ep(rqpn->dma_map_vi); 216 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID5] = dma_mapping_to_ep(rqpn->dma_map_vi); 217 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID6] = dma_mapping_to_ep(rqpn->dma_map_vo); 218 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID7] = dma_mapping_to_ep(rqpn->dma_map_vo); --> 219 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID8] = -EINVAL; Can't save negative error codes to a u8. 220 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID9] = -EINVAL; 221 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID10] = -EINVAL; 222 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID11] = -EINVAL; 223 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID12] = -EINVAL; 224 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID13] = -EINVAL; 225 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID14] = -EINVAL; 226 rtwusb->qsel_to_ep[TX_DESC_QSEL_TID15] = -EINVAL; 227 rtwusb->qsel_to_ep[TX_DESC_QSEL_BEACON] = dma_mapping_to_ep(rqpn->dma_map_hi); 228 rtwusb->qsel_to_ep[TX_DESC_QSEL_HIGH] = dma_mapping_to_ep(rqpn->dma_map_hi); 229 rtwusb->qsel_to_ep[TX_DESC_QSEL_MGMT] = dma_mapping_to_ep(rqpn->dma_map_mg); 230 rtwusb->qsel_to_ep[TX_DESC_QSEL_H2C] = dma_mapping_to_ep(rqpn->dma_map_hi); 231 232 return 0; 233 } regards, dan carpenter