From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2ECD0C4332F for ; Sat, 24 Dec 2022 01:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236586AbiLXBby (ORCPT ); Fri, 23 Dec 2022 20:31:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236323AbiLXBbT (ORCPT ); Fri, 23 Dec 2022 20:31:19 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8DDE303D8; Fri, 23 Dec 2022 17:30:24 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id BEE3CB821B7; Sat, 24 Dec 2022 01:30:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD721C433D2; Sat, 24 Dec 2022 01:30:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671845416; bh=v05YtagQilWYyBP35pywbT1fDrboLNZJRHlRDODJlk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISmv5U9W4oy3sqvO8OiKy1iB5Zq69uSjJ36Ih7GnbZUTWrV5QJStOPIUzHxojLv9s saGM526IzA9XSlXRz3PrZcc6khGbqF2lifvNa5lXueeybsaSl7ZdMjqiUsmxyLivMz OkOU1Iu8hotPT/Kptc/lM2K+zjafa+TCjrr3XOtcqYIC0/Enjmtk+Rreny+/9iqavE C1rc0lTqww3s6s0IgbT0qJzQfK7eufDCJosO0l+VVkuzriE5EdjPV90EnY3yccis3W xfL8WFM0PsWZPFAX1wA38mEAUmb5/m+l4RzI+3vTh4zuYvF777MmE2Zas4YEe6f12W 0mBPz73Sqx4Xw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Shuah Khan , Greg Kroah-Hartman , Sasha Levin , valentina.manea.m@gmail.com, shuah@kernel.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 16/26] usb/usbip: Fix v_recv_cmd_submit() to use PIPE_BULK define Date: Fri, 23 Dec 2022 20:29:20 -0500 Message-Id: <20221224012930.392358-16-sashal@kernel.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221224012930.392358-1-sashal@kernel.org> References: <20221224012930.392358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shuah Khan [ Upstream commit dd65a243a915ca319ed5fee9161a168c836fa2f2 ] 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 build time check for PIPE_BULK != 3 as the code path depends on PIPE_BULK = 3. Signed-off-by: Shuah Khan Link: https://lore.kernel.org/r/20221110194738.38514-1-skhan@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/usb/usbip/vudc_rx.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c index d4a2f30a7580..51bb70837b90 100644 --- a/drivers/usb/usbip/vudc_rx.c +++ b/drivers/usb/usbip/vudc_rx.c @@ -149,7 +149,9 @@ 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); + BUILD_BUG_ON_MSG(PIPE_BULK != 3, "PIPE_* doesn't range from 0 to 3"); + + urb_p->urb->pipe &= ~(PIPE_BULK << 30); switch (urb_p->ep->type) { case USB_ENDPOINT_XFER_BULK: urb_p->urb->pipe |= (PIPE_BULK << 30); -- 2.35.1