From patchwork Thu Nov 3 13:12:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 14870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp523052wru; Thu, 3 Nov 2022 06:14:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6LIoHbrK7QZv5sKGBtnVWHc/wiJ9sbB/u72KszKWRSM5nQ0s2d/NGtKszF1NcvaNjQmj6/ X-Received: by 2002:a17:906:cc58:b0:7a9:6b4e:79e4 with SMTP id mm24-20020a170906cc5800b007a96b4e79e4mr28071517ejb.57.1667481261517; Thu, 03 Nov 2022 06:14:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667481261; cv=none; d=google.com; s=arc-20160816; b=qybdF2MMbrG1HGrj8MghCzh6Zz0Zi9m61G+JjPFalboNdXUaJGqTQvK7qWB3Ynjg5T rMAkLHltFcBCTvsziNuHukS7qwUCYpIIQ0qBcl5nxtdlvtWas8lv9WO4OC86PWnoAImN uUTxWdtrI0IzlY7mCywIUNjBeXDJM1bdVSoqdAKI97zBDPtT713poVSHaQs69aP51q4c jj2NX7TceTcCG3yT/wEgkqy/E2YpWDJm33+H19QF+Pju1zIjGIwiSua1t13qnho1qdHz 1u8lkgJHv69hrRx4+FnHOL+8gWHuWOL1pnla8toI7jwmDphD997oq4v1fySQafwGw6T/ W3nQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=La6137YO6O3TJK/0GFcDignRrRdua80P+6PCRQgIvsM=; b=fCKmpxyQE8eg3lFSH+UJ/o+VDEPr5UopSKOMX0GELXlGTZAhQG6serb+ADphyGhaV4 kNCD87sbDCWsxvZJkwob66dDeZN9qBpFAhxb/tN4PNwjHGzDWZQIviY5ci79HI7L06w0 ea9+xZCj6LUcVgyDaYY+AnMSdwn2MXlQcqSTZmH48NGfvLgM7czK+pDZRNC10wGYFG5q S/OXrDxvK7wCLPpMHWVUzPySHSl8eFk7Cx7i+KV3mCLrpbFPtadO3Y+STyogcKUDUoxZ g/g88Pu5+z5FR5PDThtmT10oqL6s4fkH3dfuQXuUqsep2Nbpsz3+j4YDPhjuILomMwwA Q0yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=DSclgAj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm23-20020a05640222d700b0046277d2cb0csi1065416edb.470.2022.11.03.06.13.55; Thu, 03 Nov 2022 06:14:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=google header.b=DSclgAj2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231487AbiKCNNA (ORCPT + 99 others); Thu, 3 Nov 2022 09:13:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbiKCNMy (ORCPT ); Thu, 3 Nov 2022 09:12:54 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4995914D3B for ; Thu, 3 Nov 2022 06:12:53 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id b1-20020a17090a7ac100b00213fde52d49so1748965pjl.3 for ; Thu, 03 Nov 2022 06:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=La6137YO6O3TJK/0GFcDignRrRdua80P+6PCRQgIvsM=; b=DSclgAj23WinjREjPzdCRDM1MdJhbVwuzU56c+TRZXuKWWkmEci1xkgsiDFwn+eJRC 2n8y6N+snvNwKCwxvvPe42FZ3i7KJO3npl4+HIJpKit6MQkJ3hH3j1MIg6YJwCzqV5aS F8DogQkMVdadB5/zArnJD6RKDiFRoznOXT3Sg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=La6137YO6O3TJK/0GFcDignRrRdua80P+6PCRQgIvsM=; b=5kyTHFLButTt+WZfNhjcFYkSxs9FUtmA7AURYnsFqO673nUFGg5eBBd2AegMarevxr wibMNP40xtqW71krEqQjkYY5RkER2TceeDQjckueuVsFt5bOaD2MqWWrOUlN7FD7/E3d 9sDzdx7Dxb4WIuy2z4B7A8wun//Qyx3DUUzpGQscbPBb0AqLk0svEa8K1yrvR2zyO3c2 c2TQpkYPsGJbRF9/K5DuCV8VvfdCB4jHedTJnYnR4FSYxyjVE7NpkN4bBFG7agbkodDo /r9worM2JZItbxszhsc3pvMTdHk+2PLk4kO+NkWy9QPfEgTEKnb3hkJHIL40/wMwwyOY Q2/A== X-Gm-Message-State: ACrzQf0v5m6+zPvwOoAQB7V7Bnr+Xrt0d8N0Bz/nT5Q+fIWSeqUmnVDw 9usgjq0+Ni1hXTz3kfURNDV8sg== X-Received: by 2002:a17:902:8c92:b0:178:29d4:600f with SMTP id t18-20020a1709028c9200b0017829d4600fmr30344420plo.40.1667481172527; Thu, 03 Nov 2022 06:12:52 -0700 (PDT) Received: from shuah-tx13.. ([103.99.10.63]) by smtp.gmail.com with ESMTPSA id p8-20020a1709027ec800b0018703bf3ec9sm647871plb.61.2022.11.03.06.12.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 06:12:51 -0700 (PDT) From: Shuah Khan To: shuah@kernel.org, valentina.manea.m@gmail.com Cc: Shuah Khan , gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] usb/usbip: fix uninitialized variables errors Date: Thu, 3 Nov 2022 07:12:42 -0600 Message-Id: <76654f2f1cc30b27be10ac9b177bb449a7ad7068.1667480280.git.skhan@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748480831039725831?= X-GMAIL-MSGID: =?utf-8?q?1748480831039725831?= Fix uninitialized variable errors reported by cppcheck. One example below. usbip/stub_main.c:284:10: error: Uninitialized variables: priv.seqnum, priv.sdev, priv.urbs, priv.sgl, priv.num_urbs, priv.completed_urbs, priv.urb_status, priv.unlinking [uninitvar] return priv; Signed-off-by: Shuah Khan --- drivers/usb/usbip/stub_main.c | 2 +- drivers/usb/usbip/stub_rx.c | 4 ++-- drivers/usb/usbip/stub_tx.c | 4 ++-- drivers/usb/usbip/usbip_event.c | 2 +- drivers/usb/usbip/vhci_hcd.c | 2 +- drivers/usb/usbip/vhci_rx.c | 2 +- drivers/usb/usbip/vhci_tx.c | 4 ++-- drivers/usb/usbip/vudc_dev.c | 2 +- drivers/usb/usbip/vudc_rx.c | 2 +- drivers/usb/usbip/vudc_transfer.c | 4 ++-- 10 files changed, 14 insertions(+), 14 deletions(-) diff --git a/drivers/usb/usbip/stub_main.c b/drivers/usb/usbip/stub_main.c index e8c3131a8543..e1248b971218 100644 --- a/drivers/usb/usbip/stub_main.c +++ b/drivers/usb/usbip/stub_main.c @@ -277,7 +277,7 @@ static DRIVER_ATTR_WO(rebind); static struct stub_priv *stub_priv_pop_from_listhead(struct list_head *listhead) { - struct stub_priv *priv, *tmp; + struct stub_priv *priv = NULL, *tmp; list_for_each_entry_safe(priv, tmp, listhead, list) { list_del_init(&priv->list); diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c index fc01b31bbb87..08e11948834b 100644 --- a/drivers/usb/usbip/stub_rx.c +++ b/drivers/usb/usbip/stub_rx.c @@ -206,7 +206,7 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev, { int ret, i; unsigned long flags; - struct stub_priv *priv; + struct stub_priv *priv = NULL; spin_lock_irqsave(&sdev->priv_lock, flags); @@ -440,7 +440,7 @@ static void masking_bogus_flags(struct urb *urb) static int stub_recv_xbuff(struct usbip_device *ud, struct stub_priv *priv) { - int ret; + int ret = 0; int i; for (i = 0; i < priv->num_urbs; i++) { diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c index b1c2f6781cb3..3d3d2b5a680d 100644 --- a/drivers/usb/usbip/stub_tx.c +++ b/drivers/usb/usbip/stub_tx.c @@ -132,7 +132,7 @@ static void setup_ret_unlink_pdu(struct usbip_header *rpdu, static struct stub_priv *dequeue_from_priv_tx(struct stub_device *sdev) { unsigned long flags; - struct stub_priv *priv, *tmp; + struct stub_priv *priv = NULL, *tmp; spin_lock_irqsave(&sdev->priv_lock, flags); @@ -343,7 +343,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) static struct stub_unlink *dequeue_from_unlink_tx(struct stub_device *sdev) { unsigned long flags; - struct stub_unlink *unlink, *tmp; + struct stub_unlink *unlink = NULL, *tmp; spin_lock_irqsave(&sdev->priv_lock, flags); diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c index 26513540bcdb..8d782c8d8893 100644 --- a/drivers/usb/usbip/usbip_event.c +++ b/drivers/usb/usbip/usbip_event.c @@ -143,7 +143,7 @@ void usbip_finish_eh(void) void usbip_event_add(struct usbip_device *ud, unsigned long event) { - struct usbip_event *ue; + struct usbip_event *ue = NULL; unsigned long flags; if (ud->event & USBIP_EH_BYE) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index 233265550fc6..79503ffc3db8 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -957,7 +957,7 @@ static void vhci_cleanup_unlink_list(struct vhci_device *vdev, struct vhci_hcd *vhci_hcd = vdev_to_vhci_hcd(vdev); struct usb_hcd *hcd = vhci_hcd_to_hcd(vhci_hcd); struct vhci *vhci = vhci_hcd->vhci; - struct vhci_unlink *unlink, *tmp; + struct vhci_unlink *unlink = NULL, *tmp; unsigned long flags; spin_lock_irqsave(&vhci->lock, flags); diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c index 7f2d1c241559..8edb699aed23 100644 --- a/drivers/usb/usbip/vhci_rx.c +++ b/drivers/usb/usbip/vhci_rx.c @@ -12,7 +12,7 @@ /* get URB from transmitted urb queue. caller must hold vdev->priv_lock */ struct urb *pickup_urb_and_free_priv(struct vhci_device *vdev, __u32 seqnum) { - struct vhci_priv *priv, *tmp; + struct vhci_priv *priv = NULL, *tmp; struct urb *urb = NULL; int status; diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c index 0ae40a13a9fe..78b96c915724 100644 --- a/drivers/usb/usbip/vhci_tx.c +++ b/drivers/usb/usbip/vhci_tx.c @@ -33,7 +33,7 @@ static void setup_cmd_submit_pdu(struct usbip_header *pdup, struct urb *urb) static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev) { - struct vhci_priv *priv, *tmp; + struct vhci_priv *priv = NULL, *tmp; unsigned long flags; spin_lock_irqsave(&vdev->priv_lock, flags); @@ -168,7 +168,7 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev) static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev) { - struct vhci_unlink *unlink, *tmp; + struct vhci_unlink *unlink = NULL, *tmp; unsigned long flags; spin_lock_irqsave(&vdev->priv_lock, flags); diff --git a/drivers/usb/usbip/vudc_dev.c b/drivers/usb/usbip/vudc_dev.c index 2bc428f2e261..ddf7e6f18439 100644 --- a/drivers/usb/usbip/vudc_dev.c +++ b/drivers/usb/usbip/vudc_dev.c @@ -90,7 +90,7 @@ static void nuke(struct vudc *udc, struct vep *ep) static void stop_activity(struct vudc *udc) { int i; - struct urbp *urb_p, *tmp; + struct urbp *urb_p = NULL, *tmp; udc->address = 0; diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c index d4a2f30a7580..a6ca27f10b68 100644 --- a/drivers/usb/usbip/vudc_rx.c +++ b/drivers/usb/usbip/vudc_rx.c @@ -63,7 +63,7 @@ static int v_recv_cmd_unlink(struct vudc *udc, struct usbip_header *pdu) { unsigned long flags; - struct urbp *urb_p; + struct urbp *urb_p = NULL; spin_lock_irqsave(&udc->lock, flags); list_for_each_entry(urb_p, &udc->urb_queue, urb_entry) { diff --git a/drivers/usb/usbip/vudc_transfer.c b/drivers/usb/usbip/vudc_transfer.c index 7e801fee33bf..fd5547f85de9 100644 --- a/drivers/usb/usbip/vudc_transfer.c +++ b/drivers/usb/usbip/vudc_transfer.c @@ -183,7 +183,7 @@ static int handle_control_request(struct vudc *udc, struct urb *urb, static int transfer(struct vudc *udc, struct urb *urb, struct vep *ep, int limit) { - struct vrequest *req; + struct vrequest *req = NULL; int sent = 0; top: /* if there's no request queued, the device is NAKing; return */ @@ -303,7 +303,7 @@ static void v_timer(struct timer_list *t) { struct vudc *udc = from_timer(udc, t, tr_timer.timer); struct transfer_timer *timer = &udc->tr_timer; - struct urbp *urb_p, *tmp; + struct urbp *urb_p = NULL, *tmp; unsigned long flags; struct usb_ep *_ep; struct vep *ep; From patchwork Thu Nov 3 13:12:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shuah Khan X-Patchwork-Id: 14871 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp524335wru; Thu, 3 Nov 2022 06:16:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52cQHzSG5NmfBCESvi/0d28hiZMr6hQDNEbbuo98JP7EO+ORSuLrSq5qfG5qFmTmR9He3K X-Received: by 2002:a17:907:a422:b0:7a6:c4cb:dd42 with SMTP id sg34-20020a170907a42200b007a6c4cbdd42mr28157073ejc.735.1667481371088; Thu, 03 Nov 2022 06:16:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667481371; cv=none; d=google.com; s=arc-20160816; b=p0C+eDFyAZ/vrzNXTjmFsvVZ2REBDbjsrtVrx2WrN6o4/kTICPObarURskYZdioMgs 8L7lJYah+DP1efuuxVcaf7LMmpZSuwPn4XrUkhWLU7LRRxnesEC48Bq3Bmy/2rg+xTcX HKa2PnAwIorQqQX4hs1ntwG5QpyZolzhryAssNwPbc/s4uPjKW3fR3YXnn5B9sb8Qb4o MJUUgGNz6wqc6EQg4qE6LLSgq4crcnQIMlk27RZJdUIOY3e5JL19Scgsi4rMmtqadgCI zjoJFmJPTlrJ9dmjdWGffv4dBpHV9z46L9M7xF/DKvha/8CCkf51Yed3PqhetdF+ycUD aniw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=f7xraXG/GileYO3tPwQFVcfRIK9dP1/TT5c9Q1u4UMU=; b=DYnCkvbuJ/ggJvRVqKZzs/a5YdrpErfVxoaI6UOZTbGQJ4SIqaKrtJKY/exCWg/oaN x35OiFvv6GWOOXFPj2X+bP27uPcVeAdINakLDuDH5hUeASh2Oo+IRx/Ul/ivucNBaHJk JPe6hQ3ugNQUPmQdLT2tdhYgIEV7QDmx744IzYKLn5uBGHASkOVpR3WGMKi9cyOCVmwS mucAmwgl3gemjnsH26kWq+n2KdptWu/KI6ZuuL09Ru1WLRZ3Idud27AP0mF+ynRAiVRc zhsLZpwiLXtkA3x3LVzLRAcPFCaCbXvq4jtMk6RO8cFFGO1UzcPY7TCyRoXa99RShxLr 57Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=QHWz+PU8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q19-20020a50cc93000000b00461a98a20cbsi1285151edi.187.2022.11.03.06.15.45; Thu, 03 Nov 2022 06:16:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@linuxfoundation.org header.s=google header.b=QHWz+PU8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231372AbiKCNNC (ORCPT + 99 others); Thu, 3 Nov 2022 09:13:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231318AbiKCNM4 (ORCPT ); Thu, 3 Nov 2022 09:12:56 -0400 Received: from mail-pj1-x102b.google.com (mail-pj1-x102b.google.com [IPv6:2607:f8b0:4864:20::102b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E08DE1409E for ; Thu, 3 Nov 2022 06:12:55 -0700 (PDT) Received: by mail-pj1-x102b.google.com with SMTP id u8-20020a17090a5e4800b002106dcdd4a0so5154271pji.1 for ; Thu, 03 Nov 2022 06:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=f7xraXG/GileYO3tPwQFVcfRIK9dP1/TT5c9Q1u4UMU=; b=QHWz+PU8C9ejrxpJjFKO8yxQAEIOfgWd0jmIVuiJkFcZu8Xcg8SJAg/+iDGWyC3T8a uhf19QtvGRTBzoqKI0cjFaUxOA7BZtOxTDoXpLvTFoOdsMvjoHCkalG+oQC8lSMQv6IT iXiwMMO3N5SpjomNi02WrWy6ckVRsfvt4+DfQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=f7xraXG/GileYO3tPwQFVcfRIK9dP1/TT5c9Q1u4UMU=; b=D17w1C29/TRxC43SI72uE0a+a34pNU4eVvmlhqQB0Vanh6zZAT4wOF1HvAH+ptf5WF vNDbY3VBoRZSLC2ESkwmVx04v+Dd8zjaebrU+VUNkbM3qOX/+pMf/m05wCjZcLTHRwRH +A2oLEKPtc7q5XR7ZhILfVtcnVVGvpam2EJr1lOZtgjF8bsIM+j6Ovy3OUVwRIso6M7B PFpQdgUrFZOD9RWWA16OvZQuzHfJfueRDrCBaXchb8GFl/dqDD9Kgi6QjCQg4iwFxQ0t t8Wo7+x3lsr5YFz9fGOGSusy2du4a02+hUYryPvl5AIgIiGjMx8cxqgDcq6mc5dKxgcP 9PRA== X-Gm-Message-State: ACrzQf2OuNhXE7TJEz3ypZzqGoboCJ/p+OYWObt2pclQ02sqVRxsOiiB 0Q8VnfEbmmX6Bi+TGCLA3E5UUQ== X-Received: by 2002:a17:90a:930b:b0:20b:a5d:35d6 with SMTP id p11-20020a17090a930b00b0020b0a5d35d6mr48008379pjo.146.1667481175341; Thu, 03 Nov 2022 06:12:55 -0700 (PDT) Received: from shuah-tx13.. ([103.99.10.63]) by smtp.gmail.com with ESMTPSA id p8-20020a1709027ec800b0018703bf3ec9sm647871plb.61.2022.11.03.06.12.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 06:12:54 -0700 (PDT) From: Shuah Khan To: shuah@kernel.org, valentina.manea.m@gmail.com Cc: Shuah Khan , gregkh@linuxfoundation.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] usb/usbip: Fix v_recv_cmd_submit() to use PIPE_BULK define Date: Thu, 3 Nov 2022 07:12:43 -0600 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS 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-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748480946010232733?= X-GMAIL-MSGID: =?utf-8?q?1748480946010232733?= Fix v_recv_cmd_submit() to use PIPE_BULK define instead of hard coded values. This also fixes the following signed integer overflow error reported by cppcheck. This is not an issue since pipe is unsigned int. However, this change improves the code to use proper define. drivers/usb/usbip/vudc_rx.c:152:26: error: Signed integer overflow for expression '3<<30'. [integerOverflow] urb_p->urb->pipe &= ~(3 << 30); In addition, add a sanity check for PIPE_BULK != 3 as the code path depends on PIPE_BULK = 3. Signed-off-by: Shuah Khan --- drivers/usb/usbip/vudc_rx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c index a6ca27f10b68..e7e0eb6bbca0 100644 --- a/drivers/usb/usbip/vudc_rx.c +++ b/drivers/usb/usbip/vudc_rx.c @@ -149,7 +149,10 @@ static int v_recv_cmd_submit(struct vudc *udc, urb_p->urb->status = -EINPROGRESS; /* FIXME: more pipe setup to please usbip_common */ - urb_p->urb->pipe &= ~(3 << 30); +#if PIPE_BULK != 3 +#error "Sanity check failed, this code presumes PIPE_... to range from 0 to 3" +#endif + urb_p->urb->pipe &= ~(PIPE_BULK << 30); switch (urb_p->ep->type) { case USB_ENDPOINT_XFER_BULK: urb_p->urb->pipe |= (PIPE_BULK << 30);