Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1978572pxb; Fri, 5 Mar 2021 04:38:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/FCFkCnWuTXxVciIw66bA6cLSjSBu31mYdb6hTXbX5Iw2xH0Cy6mtffXTlpWgGPdPaIyb X-Received: by 2002:a17:907:778d:: with SMTP id ky13mr2029783ejc.291.1614947906736; Fri, 05 Mar 2021 04:38:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947906; cv=none; d=google.com; s=arc-20160816; b=wuoT7VyJjn5RZDCnkI1qHwvEcpsuuieS+C6K7FvnzN76WHmxvspsaheEoAaRxr0I4b jFYCt5yoNc8jgOYq/jB0YSJsMlrci4tSbv+6bmm1Jl+XoB/ruvRtLbaBnalD9WWCRlWT z+UlJTKh7l9Ih9AsSvAj/dGf7OzVS4pwKNoIWxAFj/dSwcVqEvdxjYM+Y5GVRgNkdNrJ QX9auYjqM3i7PNS5Vyb86CrvblUVJlnzV5OAMwWOskXiWy9VC1Uyah1uyFTip5zYMs8k CwD7mxPXThYUVOO0fjvGGr7yVkSPf0KILksz1DA3SfwLyw4NrlGsp/aQDnvzmu80i5Tp TPtg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4KT02CzLVFHtBs+XIFhW7sYY3CMzwLM/JDMbdscPInk=; b=rvbZM0otIGwybII8A6wU+pcHpjJfvu6J5mxzVWB9kPR3D6gTTZ2P7CyAvqG2RCcFRK 0HhWX6mEQ/bVEznljs4hIs2RbVJUIqup2mwIUpqz2tQx5eDAFaXxQL1/pYskXtybNT1b FYjDhCtQc9kgl/8JbgdPuqJRauMPkUczslUU2mZw4iRMU+mZaZy/XO/bcxLw6p2XdbGG I50kfq1bvSfBbgsRjOZ1RygI7g6IjkF5z4UtoZwZ8fBfZuSNNCX8TBVLIXnNS1UcRfO7 JRDX0PbxigzwQ0L14VoVu/7LuYapaP9PxH9xlG4oNLvLOts7+DvsSf+EBdmu1k3HD7ex 0Rxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dalpgcfb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si1189996ejr.388.2021.03.05.04.38.02; Fri, 05 Mar 2021 04:38:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dalpgcfb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232795AbhCEMfu (ORCPT + 99 others); Fri, 5 Mar 2021 07:35:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:47440 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231435AbhCEMfR (ORCPT ); Fri, 5 Mar 2021 07:35:17 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9348F6501D; Fri, 5 Mar 2021 12:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947717; bh=da4wSEbWf9jUFyW2VVnf3eblEItcmiytNUB45xpDgoM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dalpgcfbDZ0hiU2cnI8c70kk97HIDvjVA4lfmqk88oOiU3jzJqW3gtlcZL0zJ6Pp9 HIPnKpdPc0EQ+yCvu9Qg+PpTZeqs+eyGoF2tV/fXldMsezyKpabry9Hsmy7fDAs0RZ Dbe+LIwBT9TrOybGySBKnrmD8RBEf1JVWTdzkdJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Sasha Levin Subject: [PATCH 5.4 28/72] staging: fwserial: Fix error handling in fwserial_create Date: Fri, 5 Mar 2021 13:21:30 +0100 Message-Id: <20210305120858.713904335@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dinghao Liu [ Upstream commit f31559af97a0eabd467e4719253675b7dccb8a46 ] When fw_core_add_address_handler() fails, we need to destroy the port by tty_port_destroy(). Also we need to unregister the address handler by fw_core_remove_address_handler() on failure. Signed-off-by: Dinghao Liu Link: https://lore.kernel.org/r/20201221122437.10274-1-dinghao.liu@zju.edu.cn Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/fwserial/fwserial.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/fwserial/fwserial.c b/drivers/staging/fwserial/fwserial.c index aec0f19597a9..4df6e3c1ea96 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -2189,6 +2189,7 @@ static int fwserial_create(struct fw_unit *unit) err = fw_core_add_address_handler(&port->rx_handler, &fw_high_memory_region); if (err) { + tty_port_destroy(&port->port); kfree(port); goto free_ports; } @@ -2271,6 +2272,7 @@ unregister_ttys: free_ports: for (--i; i >= 0; --i) { + fw_core_remove_address_handler(&serial->ports[i]->rx_handler); tty_port_destroy(&serial->ports[i]->port); kfree(serial->ports[i]); } -- 2.30.1