From patchwork Fri Sep 2 03:20:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiasheng Jiang X-Patchwork-Id: 12963593 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 41965ECAAA1 for ; Fri, 2 Sep 2022 03:28:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234064AbiIBD2W (ORCPT ); Thu, 1 Sep 2022 23:28:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37444 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230271AbiIBD2T (ORCPT ); Thu, 1 Sep 2022 23:28:19 -0400 X-Greylist: delayed 491 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 01 Sep 2022 20:28:18 PDT Received: from cstnet.cn (smtp23.cstnet.cn [159.226.251.23]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 286C18B2C8 for ; Thu, 1 Sep 2022 20:28:17 -0700 (PDT) Received: from localhost.localdomain (unknown [124.16.138.126]) by APP-03 (Coremail) with SMTP id rQCowABXX0tjdhFjm_xwAA--.15986S2; Fri, 02 Sep 2022 11:20:04 +0800 (CST) From: Jiasheng Jiang To: johan@kernel.org, gregkh@linuxfoundation.org Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Jiasheng Jiang Subject: [PATCH] USB: serial: ftdi_sio: Add check for create_sysfs_attrs Date: Fri, 2 Sep 2022 11:20:02 +0800 Message-Id: <20220902032002.3859368-1-jiasheng@iscas.ac.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CM-TRANSID: rQCowABXX0tjdhFjm_xwAA--.15986S2 X-Coremail-Antispam: 1UD129KBjvd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fou0/ Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org As create_sysfs_attrs() can return error number, it should be better to check the return value and deal with the exception. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Jiasheng Jiang --- drivers/usb/serial/ftdi_sio.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/usb/serial/ftdi_sio.c b/drivers/usb/serial/ftdi_sio.c index d5a3986dfee7..c28f894430a5 100644 --- a/drivers/usb/serial/ftdi_sio.c +++ b/drivers/usb/serial/ftdi_sio.c @@ -2251,7 +2251,11 @@ static int ftdi_sio_port_probe(struct usb_serial_port *port) if (read_latency_timer(port) < 0) priv->latency = 16; write_latency_timer(port); - create_sysfs_attrs(port); + result = create_sysfs_attrs(port); + if (result) { + remove_sysfs_attrs(port); + return result; + } result = ftdi_gpio_init(port); if (result < 0) {