From patchwork Fri Jul 21 10:00:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: liulongfang X-Patchwork-Id: 13321799 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 950B1EB64DD for ; Fri, 21 Jul 2023 10:02:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230193AbjGUKCV (ORCPT ); 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 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 Precedence: bulk List-ID: X-Mailing-List: linux-usb@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 ==