Received: by 2002:a05:6358:111d:b0:dc:6189:e246 with SMTP id f29csp1585718rwi; Thu, 3 Nov 2022 07:01:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM50bLf9bHz+R42BOtW8XSm0W1gAyjC/bF3I1MYUxzsLrtZXBzrDc/fqPWz5pmH3VviXVV1g X-Received: by 2002:a17:90a:f306:b0:213:b191:f3bf with SMTP id ca6-20020a17090af30600b00213b191f3bfmr29262800pjb.237.1667484082345; Thu, 03 Nov 2022 07:01:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667484082; cv=none; d=google.com; s=arc-20160816; b=FDVkpbTGB13Wz0UQCxOgeLoz9+LSjQtTobolAyNJqhHrrs9ygy9oxoMNWwifxR/6/m WoiyeFRXAk3aEzCZ6TMiqRb1kuGU4BjMacYm3TpwcgHpncGUVoGuIsQ2fp+I7UQmhMnP gQvZ7cgUH94ZDC/N0ZD56+lFqPLpMBAG8OGKaq6oEBzLInI3CN15j3FVr82ih57tM9gb s2S0J3bzAJDy/vz6J0LTLcn+0NFPcdTjpHJCQWpxicRevvaEFU9cY4VAKgyKqwhp3+gZ Clorxc2pVhg8FRGBwErzQy5yarjDdc5Pgd3HByja1iLqDNlibnK1uC5OOIuc/ItqQQ+3 8PTA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=MZUe65nnJazLP/QUsLTShF/mPKtq4MOeGO0nXDu+pwM=; b=0L30yTvhrT5dOeAcKtwOzC8mlt76OshQoNw55r8TWjoh5otweF7njXs0sLSpP+3IaI M4dWtg2zKTet6OppjQvcJyfGrKyfdkjn/l+AAdOvnaQm2Wlq7RzCoI2bhmBbMJCz/tc6 CfPKlVx/IhJjY+ZdQLVT5nRJn2TBIhk2lnyKlpZ7cGuLxX8fpz9TM/0bwTj5W9iJ5WuT 09qjxBQCx83ZjgKBkc3t6ypHyCI2w8fCNOYTAjy3WFNkVT/iIK9iOg/FySl8WLMgSq1s wOZa/iXYvbjJodHx0SVxQBM5ySAxhTZJrEyiSwpv1+Jo5VqJCxJ7GIt/rsNf3NZX843Y BazA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=H0jYwksa; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s73-20020a63774c000000b00460b572d264si1100566pgc.579.2022.11.03.07.00.55; Thu, 03 Nov 2022 07:01:22 -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=korg header.b=H0jYwksa; 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 S231467AbiKCNXo (ORCPT + 97 others); Thu, 3 Nov 2022 09:23:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229570AbiKCNXm (ORCPT ); Thu, 3 Nov 2022 09:23:42 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9D1FAC53; Thu, 3 Nov 2022 06:23:41 -0700 (PDT) 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 5A551B82798; Thu, 3 Nov 2022 13:23:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9903AC433D7; Thu, 3 Nov 2022 13:23:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1667481819; bh=Ptts9H7CMiwi/Nx896qtMeZvxnyHeELD05B85Sla9Yk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=H0jYwksaXvB5Vk5tvv3rWzUqTcxijVVas/QEdj/xij+0Fy6/Nj8zXLyG6HjShpIoj cC1vGftaHsd76TGUaIzhrORqJ+vXtQYWHEEP8j6CTOKPo6ne6ZNam0FO6aDGR/5NnS dqhZBldoSuX8EbW4nuQKa4P0v9318WIdc6rU+aaI= Date: Thu, 3 Nov 2022 22:24:19 +0900 From: Greg KH To: Shuah Khan Cc: shuah@kernel.org, valentina.manea.m@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/2] usb/usbip: Fix v_recv_cmd_submit() to use PIPE_BULK define Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, 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 On Thu, Nov 03, 2022 at 07:12:43AM -0600, Shuah Khan wrote: > 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 Perhaps use BUILD_BUG_ON() instead of hand-rolling one? thanks, greg k-h