Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp431818pxb; Wed, 24 Feb 2021 06:10:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJzbb4JTqZ1RUFKlaIzipA6o4jG8PIypx7vfDpLYdw1YbHDIobDNRWcpVpOk8agSBuuqStY8 X-Received: by 2002:a17:906:958b:: with SMTP id r11mr30707111ejx.23.1614175849296; Wed, 24 Feb 2021 06:10:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614175849; cv=none; d=google.com; s=arc-20160816; b=WpFohScYXd8BFFey8aJb30WjG9aRbrLdjaFr2DT7YJ+rDqbHgpnXaKHSMfknWhCMJR uVAd4okgAzZqZB0UUNdCOxCTgOKq7UMX8S+QLsQg2FafvmiNhAld8tSqjSr80TELjqR6 jqkx6TeMlez7jFlKvHyZxeHP0olmk4coJKvkYg1+nJ+mivWgp1Cu9E0EKY+LBVGlNpC/ tDUJnDIIYoK3xFvK2gkj0MdHtm0JVei5Tw9FFKrNGdjVy9Anv+juXXjAPa9XFTSCiOxm +D9U8oLIRf7sfc96CK3cgpGxZU2iI3WgFaJ9MsMOwhbO4ofal/w2IsrUVZmdUGgqqqjM lSDw== 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:dkim-signature; bh=e3wQsuORORtZbIFrr1VjVf31TT+0c5oG6j1F9euYk+M=; b=fIREGWUDlSjnO0bfJSrEs6BR3el3/pns8lZg2/l8YX4tw31ZJVxuaC5Mxl3qbgT1ju cwMPJONXptyL1tiTDzHM98A3Q9kfriqSqlhervAsWzDAourlXQjQqjWEU+VTrfogodXN 9mCu/QmQbhBIUzpOHnFe8sbuSh1SQ6pau4bGONkD1sd6JgwnY1C6U0pqkutgyyGp13uZ ndAmMryzn8I2uxu5yMie+Ns1QQIrm7CaT/xJDAB8x1Kq2bTgh4WxbY2Z2OdThk+gU8jQ wUDdIucywhNu1h+pBhn/DnNFwb5QmjivGTwjFhXKZxjOUOrkGCI3TvEiyVDz4wkBFtbe mFzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=I0tqgeU7; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q15si1234892ejc.113.2021.02.24.06.10.20; Wed, 24 Feb 2021 06:10:49 -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=@kernel.org header.s=k20201202 header.b=I0tqgeU7; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbhBXOAu (ORCPT + 99 others); Wed, 24 Feb 2021 09:00:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:58102 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235899AbhBXNIB (ORCPT ); Wed, 24 Feb 2021 08:08:01 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 3DC9C64F86; Wed, 24 Feb 2021 12:54:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171277; bh=g9d5o9CMSORlYs0gjGK9mmhQhciTilxiXlvuspDOZhE=; h=From:To:Cc:Subject:Date:From; b=I0tqgeU7DQ7WHUivY72+2lYetfdsy5uTzbxjcTEBWB0QctPb3zry+EXGPcKoW7reg ccH8IGT98bv6ELpxuKt970r5KBQmctTNnFazRLNzZDVI9i06siE8BwV9xb0/MraQ+2 UvYrD4ijOKphqK/7RpIxIhGQiVfxm8S3A/sNFQLmD1sWmSPYYei8nz17Ho/Zr6t9Vx Iy9qqf5qg//Ay2B28vG4u3NQ7bOAt2Ll+fdUFK+2Ab8wOnCAinKBifDw1QMueo0YIQ G1BnfGo6ah7HLthnuZKOQK+FJ/u1vUy5PFG8uueKzJDRK2HM/LG5yyYoFrUpYKQ4UY N4Ud8o+SATsjQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Dinghao Liu , Greg Kroah-Hartman , Sasha Levin , devel@driverdev.osuosl.org Subject: [PATCH AUTOSEL 4.19 01/26] staging: fwserial: Fix error handling in fwserial_create Date: Wed, 24 Feb 2021 07:54:09 -0500 Message-Id: <20210224125435.483539-1-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 fa0dd425b4549..cd062628a46b0 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 @@ static int fwserial_create(struct fw_unit *unit) 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.27.0