Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp10680091rwp; Fri, 21 Jul 2023 03:16:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlE8cp+wD/VqDMp+0XOFblrvvrcPduTeLjFtSoHq88cTioRVym4jCCdj/pTONR6IFFg/I4+s X-Received: by 2002:a17:907:d24:b0:98e:3dac:6260 with SMTP id gn36-20020a1709070d2400b0098e3dac6260mr9813745ejc.13.1689934615158; Fri, 21 Jul 2023 03:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689934615; cv=none; d=google.com; s=arc-20160816; b=OVRfk1oCIbUjNo3YEQ8SqL3naGaU2jGGWvegfP5dbTcKbqbzGNlckXoadkinunYapg MD1x9U2vZofj3xF2jCuJRsth+vPb3Y2KeY9BJIm7My1WqnVcNbHY5Jj64HUt+KymhY5i 8oY7k5az+nGC0Na+3kRjDYZWoPHvnJceicZ+EYRrL98/Nl3okUB69HQFHEiOj9xRQrMJ qOnhZEMhjV+ElBhH9mLSZ+MwkYzbehDktiZhvVVuA2AajWWXSwAHlBZWgiWx93iL0GTJ FSBgoO5JaP4G0TfxM5Q7s8Mnduk36iImS61E1AK/fEKi2EmxO0Y6+Zoz1FH2vIq2cMMW oqDg== 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 :message-id:date:subject:cc:to:from; bh=OBWBaOCgo9T6jRXxi+hUWWzhhXs5nxTzenXXMrHfHtE=; fh=J19RnJH1B9NlXev1IVrKI976cXFqWW781AWGGMdWaps=; b=a9NDK27Ja2RAiz7Kty3Hl4Gtm2CEuScG+MxGvF2X67EvinvkdoDs9FCrKKic53LrIZ 4ImfwUfrYV5LPND61XvkcytinBPwHdUOsJFEQ5A7Y0gtoIU8zF09/DRXBoiFMQZctb3K xipHQM9l3YgQ7M8gkmqSxmeoIiN5z/VzRfPdDXUeWXT0yQPxA+w6LJtvGa5wlWPwl532 7NH+goGvAQbGCLvEzkHHogEYyRjRD8OZ0iswJm+Y3HnuYbrJ/9Tj5zbM/aDBzldopvLF x24Gd4ZB2Ype8oZBFNc/mAxqCzJsEw8aou3hAbicOWuc8XDUiS0OkSHIn/yrNNOpF5Fi cOwA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c16-20020aa7d610000000b0051e0f234b41si2188738edr.130.2023.07.21.03.16.31; Fri, 21 Jul 2023 03:16:55 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230245AbjGUKCV (ORCPT + 99 others); Fri, 21 Jul 2023 06:02:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229899AbjGUKCT (ORCPT ); Fri, 21 Jul 2023 06:02:19 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F1E0B7; Fri, 21 Jul 2023 03:02:18 -0700 (PDT) Received: from kwepemm600005.china.huawei.com (unknown [172.30.72.54]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4R6lQn60gdzHqZp; Fri, 21 Jul 2023 17:59:45 +0800 (CST) Received: from huawei.com (10.50.163.32) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Fri, 21 Jul 2023 18:02:15 +0800 From: liulongfang To: CC: , Subject: [PATCH] USB:bugfix a controller halt error Date: Fri, 21 Jul 2023 18:00:15 +0800 Message-ID: <20230721100015.27124-1-liulongfang@huawei.com> X-Mailer: git-send-email 2.24.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.50.163.32] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 systems that use ECC memory. The ECC error of the memory will cause the USB controller to halt. It causes the usb_control_msg() operation to fail. At this point, the returned buffer data is an abnormal value, and continuing to use it will lead to incorrect results. Therefore, it is necessary to judge the return value and exit. Signed-off-by: liulongfang --- drivers/usb/core/hub.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index a739403a9e45..6a43198be263 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c @@ -4891,6 +4891,16 @@ hub_port_init(struct usb_hub *hub, struct usb_device *udev, int port1, USB_DT_DEVICE << 8, 0, buf, GET_DESCRIPTOR_BUFSIZE, initial_descriptor_timeout); + /* On systems that use ECC memory, ECC errors can + * cause the USB controller to halt. + * It causes this operation to fail. At this time, + * the buf data is an abnormal value and needs to be exited. + */ + if (r < 0) { + kfree(buf); + goto fail; + } + switch (buf->bMaxPacketSize0) { case 8: case 16: case 32: case 64: case 255: if (buf->bDescriptorType == -- 2.24.0