Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4295412yba; Wed, 17 Apr 2019 08:34:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqxlrFFOEInm7i5Wjkmu8IZ+NIDPwI//dNrz33u6FBRA7jvWU5YEytHjF6qSeWxxYuo3Nntw X-Received: by 2002:a62:448d:: with SMTP id m13mr90789803pfi.182.1555515274116; Wed, 17 Apr 2019 08:34:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555515274; cv=none; d=google.com; s=arc-20160816; b=K0H6yB6ZbXxA3pKGzqD24l+Q7aBxM29V0ZasrBdt7WeZWii38OMr642ELtp8ahEcz2 rSdGoh0w7a5XL6mycH+8cBBXh5MgDg40C0wBf4iHYzu4fla1AjSJ10TocCFLSc91WEMS i3ILjyBBhVHNRH6wFPNSJkWoQc2vHDdm889sWpro8VtBIA1b9bKJOP5YN0IIUGWnnCeQ 63UEuzHEqN+YybXQCSsYz4MwDrExT7hf1MCn45MYiDX952D3KsOEe00p8HUQ7KfiRW1b aW45pQye0RZAjDbJE8ReEkAQv8XSuH6kAr5o238GQOS2H3T47uZ+UhpjCa6GJ/C0i5/l yruw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :content-language:accept-language:message-id:date:thread-index :thread-topic:subject:cc:to:from; bh=ycJnqRgRJggGjklhEVohYkyjTK7gpQ3egRwIhkEm79M=; b=inQLVTbCuZHbWdkdz9dmqHY9SmvhlxRjs91fNOe1BdQvLYAdlGhqxw1GOAqxtHnK3e vDUVZrm7WzhSIY0rrcEpfg4fx8caL1G4xILdeQh1YwgpW0L41GLhHq7J85SlmTLiHgvG 6UO2GFHSklQh/dTDkEVvXjapbITZR7P6w5lUtY9+sLHMvpgzlH5yUYQXMu8DkCu5ccVY 1Dp13XP9Qp7rrUBGmrQqVcp7yJFe4uXX8aeILY2Vv+aOulU39/npw1BfoUgWLd4Pb6u8 JIkzQZu7zYqDlYGLZC6qfYy+Do1mklhiAKecwMJFuraXqJeKsf8qrZivuYEWwuJe3ITR 9dKQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j65si15444608plb.159.2019.04.17.08.34.18; Wed, 17 Apr 2019 08:34:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732634AbfDQPdY convert rfc822-to-8bit (ORCPT + 99 others); Wed, 17 Apr 2019 11:33:24 -0400 Received: from szxga02-in.huawei.com ([45.249.212.188]:2539 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729940AbfDQPdY (ORCPT ); Wed, 17 Apr 2019 11:33:24 -0400 Received: from DGGEMM401-HUB.china.huawei.com (unknown [172.30.72.54]) by Forcepoint Email with ESMTP id 1F1C43DCC1DB0F3A4AAC; Wed, 17 Apr 2019 23:33:21 +0800 (CST) Received: from dggeme761-chm.china.huawei.com (10.3.19.107) by DGGEMM401-HUB.china.huawei.com (10.3.20.209) with Microsoft SMTP Server (TLS) id 14.3.408.0; Wed, 17 Apr 2019 23:33:20 +0800 Received: from dggeme762-chm.china.huawei.com (10.3.19.108) by dggeme761-chm.china.huawei.com (10.3.19.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1591.10; Wed, 17 Apr 2019 23:33:20 +0800 Received: from dggeme762-chm.china.huawei.com ([10.8.68.53]) by dggeme762-chm.china.huawei.com ([10.8.68.53]) with mapi id 15.01.1591.008; Wed, 17 Apr 2019 23:33:20 +0800 From: "zhuyan (M)" To: Alan Stern CC: Greg KH , "anton@enomsg.org" , "linux-usb@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "zhuyan (M)" Subject: Re: [PATCH] usb:host: fix divide-by-zero in function fhci_queue_urb Thread-Topic: [PATCH] usb:host: fix divide-by-zero in function fhci_queue_urb Thread-Index: AdT1MnwO+lcz9XnHRgGSjwdOkKXG4g== Date: Wed, 17 Apr 2019 15:33:20 +0000 Message-ID: <3b062edaaafa45e2b7fb191187ef1f31@huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.40.99.186] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 17 Apr 2019, 9:45 -400, Alan Stern wrote: > On Wed, 17 Apr 2019, zhuyan (M) wrote: > > On Tue, 16 Apr 2019 11:07:56 -0400, Alan Stern wrote: > > > On Tue, 16 Apr 2019, zhuyan (M) wrote: > > > > On Tue, 16 Apr 2019 at 11:45:45 +0200, Greg KH wrote: > > > > > On Tue, Apr 09, 2019 at 10:37:12PM +0800, zhuyan wrote: > > > > > > In function fhci_queue_urb, the divisor of expression > > > > > > (urb->transfer_buffer_length % usb_maxpacket(urb->dev, > > > > > > urb->pipe, > > > > > > usb_pipeout(urb->pipe))) may be zero. > > > > > > > > > > How can you hit that? > > > > > > > > > > > When it is zero, unexpected results may occur, so it is > > > > > > necessary to ensure that the divisor is not zero. > > > > > > > > > > > > Signed-off-by: zhuyan > > > > > > > > > > I need a "Full" name here, not just a single name. Whatever you use to sign documents is good. > > > > > > > > > > thanks, > > > > > > > > > > greg k-h > > > > > > > > In function usb_maxpacket, when ep is NULL, its return value is 0. > > > > > > fhci_queue_urb() shouldn't use urb->pipe to compute the maxpacket > > > size anyway. It should use usb_endpoint_maxp(&urb->ep->desc). > > > > Currently, fhci_queue_urb(), call usb_maxpacket() multiple times to > > calculate the maxpacket size. The usb_maxpacket() will call > > usb_endpoint_maxp() to compute the maxpacket size. > > I know that. What fhci_queue_urb() is doing is wrong. You should change > it: Make it call usb_endpoint_maxp directly instead of calling usb_maxpacket. ok, I will resubmit a patch to repair it. Best wish to you! zhuyan