Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1980437pxb; Fri, 5 Mar 2021 04:41:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwK9+WfsZDmxPczwlhtmUooSd5Yg50ptTv574xjqH6Meku+4xxOuiB86lonvAxn+25hwUvi X-Received: by 2002:aa7:c1d0:: with SMTP id d16mr8719664edp.153.1614948082693; Fri, 05 Mar 2021 04:41:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614948082; cv=none; d=google.com; s=arc-20160816; b=qxvDO4phSwrGgFMacE3Slt4yzIbEYkPyL41/2tv9fg7fTzko2aNLL0EdgB/7o4OzIS xQg/gjs89D4pLMPmzEX9NPfC5aR21bZlz2gXOTuqd4sCExRZdygrDP2tpPq0n2tpiva7 qDvYeVlaExQ5S/E8YILCNB1HpS4j9YQbxEZa5APGbClgFU0X6FpcicKC6Cgn/1yeoa/5 E0+FAze5gBz37KO7sVS7DKg4ffG8CKDtKgMhj0vioo4BcnHFVlQz5eHmZ9vrnYjTLJBH biHmyhaY920NNEo16niAI1QYqqwcXiyb958+EculUtV45dVG0k0j+gDBsAKhIoM8BJfZ qwkQ== 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=97zmE/1A5x+m4rjtIyIaEz9zPL55uyz6x3B4koROJSw=; b=qw91qYT/iufkWma1YRLaD1WMI+lAIzfqhhz62Y9F5AI+/5WtpKlEw6jHixXq9B0wLK Zs5GdV2gTIlR4QbNppTVmeMFipbjcgaAFNfH7KLt/fUbrcREkfE+8zwrIsvkAT/0RfUz ICvGSW1wF8cS4ilAjQwYmF5Kz7mSlDWRkCwK9dOuj4LyuZZyAy5nrKLXy5zW1iN28qLb xwIqJMUdlHsXf3Ntxfd5Rj0t2a7tFhcGzVXKZ2Itb+kI28vyVfdybzLABy9hXOrDxViX zT995duIK6cekMaGXYGK6PW2n0WjyJMCWZ0lkdbXx++qfbLNOdfUEyTJ1jkc1Zqgg1XY HEHQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VaJrYeym; 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 f7si1273189ejw.650.2021.03.05.04.40.59; Fri, 05 Mar 2021 04:41:22 -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=VaJrYeym; 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 S232861AbhCEMh6 (ORCPT + 99 others); Fri, 5 Mar 2021 07:37:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:50104 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231694AbhCEMg5 (ORCPT ); Fri, 5 Mar 2021 07:36:57 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9721965004; Fri, 5 Mar 2021 12:36:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947817; bh=CFfvMjZor35N/S6Fn9ztZsz8Mjywf8KBGXJhclra0ko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VaJrYeymNWdKx2ZU0/U/O5daInbPT0OVu5JTpgadijh5F0gP8m8EaS7Gm8prRq4RI fRaRsVGurEcxUEapu/XyCk3lwWQ+3jtynjUNYTPe57W4SefQEnCBSTpF6VtZe4ZBjX yhUDCy05WyWwQhBqmCsjvZTtl4fOwIIw8ujGhtdg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dinghao Liu , Sasha Levin Subject: [PATCH 4.19 21/52] staging: fwserial: Fix error handling in fwserial_create Date: Fri, 5 Mar 2021 13:21:52 +0100 Message-Id: <20210305120854.721298340@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120853.659441428@linuxfoundation.org> References: <20210305120853.659441428@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 fa0dd425b454..cd062628a46b 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -2219,6 +2219,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; } @@ -2301,6 +2302,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