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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2C7A4C4332F for ; Thu, 28 Oct 2021 07:21:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EE1160F38 for ; Thu, 28 Oct 2021 07:21:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229968AbhJ1HXg (ORCPT ); Thu, 28 Oct 2021 03:23:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:56026 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229656AbhJ1HXf (ORCPT ); Thu, 28 Oct 2021 03:23:35 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 686F560E54; Thu, 28 Oct 2021 07:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635405668; bh=e/wyzVfkTV0dR6YteYW1jvF1J3q6I2+0CEvxKq0nxCE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JBkj/hcGqPxgoS4c4hfbNCE/wp/WzptPZxH+uLq1JsS0EkK8xuq2B+BFYT/M9kMdW B4lilA5IPudFk9zJtUWeypRWHZ7ScqjZP4NOuaM9yorU8jk9wi/hIqpxA9d23HhHwP C7RH/AcL97uMfN+5WAwkKf2+85pUtwc5Bcp05lYaO1hCYYYwnk0Q3u9p4ytVX0Kvef mz7WaNfGSLj5r54b82U5boDP+OLa6+8TS2VerEyuxRIwCX5V07bCEvtvTPMSuBTaTY D+D/jKbWRdviY1Qme+7BkNA36znep6njYk5ZeGs1LkQOkpyxmcXDRx0lAn4ZF71B34 0ujB0wUI0dsSA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1mfziT-00023a-77; Thu, 28 Oct 2021 09:20:49 +0200 Date: Thu, 28 Oct 2021 09:20:49 +0200 From: Johan Hovold To: Brian Norris Cc: Kalle Valo , Amitkumar Karwar , Ganapathi Bhat , Sharvari Harisangam , Xinming Hu , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Amitkumar Karwar Subject: Re: [PATCH v2 3/3] mwifiex: fix division by zero in fw download path Message-ID: References: <20211027080819.6675-1-johan@kernel.org> <20211027080819.6675-4-johan@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 27, 2021 at 11:22:39AM -0700, Brian Norris wrote: > On Wed, Oct 27, 2021 at 1:12 AM Johan Hovold wrote: > > --- a/drivers/net/wireless/marvell/mwifiex/usb.c > > +++ b/drivers/net/wireless/marvell/mwifiex/usb.c > > @@ -505,6 +505,22 @@ static int mwifiex_usb_probe(struct usb_interface *intf, > > } > > } > > > > + switch (card->usb_boot_state) { > > + case USB8XXX_FW_DNLD: > > + /* Reject broken descriptors. */ > > + if (!card->rx_cmd_ep || !card->tx_cmd_ep) > > + return -ENODEV; > > ^^ These two conditions are applicable to USB8XXX_FW_READY too, right? Right, but I didn't want to add an incomplete set of constraints. I couldn't find any documentation (e.g. lsusb -v) for what the descriptors are supposed to look like, but judging from the code, something like if (!card->rx_cmd_ep || !card->tx_cmd_ep) return -ENODEV; if (!card->rx_data_ep || !card->port[0].tx_data_ep) return -ENODEV; should do. But I'm not sure about the second tx endpoint, card->port[1].tx_data_ep, for which support was added later and which the driver appears to be able to manage without. Either way it has nothing to do with the division-by-zero and should be added separately. > > + if (card->bulk_out_maxpktsize == 0) > > + return -ENODEV; > > + break; > > + case USB8XXX_FW_READY: > > + /* Assume the driver can handle missing endpoints for now. */ > > + break; > > + default: > > + WARN_ON(1); > > + return -ENODEV; > > + } Johan