Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp438537pxb; Wed, 24 Feb 2021 06:19:04 -0800 (PST) X-Google-Smtp-Source: ABdhPJzaAFswOaD3Z1TcxfFKhJFO6N0o0L6BqmvfFqO8+BfpjIfbtxP2m2w31QQHbE424mbZxNR9 X-Received: by 2002:a17:906:301b:: with SMTP id 27mr26885377ejz.230.1614176344079; Wed, 24 Feb 2021 06:19:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614176344; cv=none; d=google.com; s=arc-20160816; b=T3ZS800Cuzpt8KTTSzUFTI/mZue7SBJv1tWrHnRb8QRfQxRUHkR0tsgA+md5/7EQsv uz+/u6afKgDja906YKfDTLuUzgkyNx5Kh2ggAMDBi4iUGUbqg+BeIAwXAfdvjCLtlUIv 8cKE5PoJZTp4PF3hXaOAFuOS2NDGz4CZxBHWmu8GY3NZpQNwqF6sIxwcsOCL675rhZaY QlZLzQP3QTNEHNw9DU+6tnxVcWbXtmwJ59tTKp+afqQnjqRZE1sBv1V3tBIGH4tt0MVR dtcP2xX2Wjzmw4plmkmrbz9oyLDA2n2r6KmcisnA7pHAwNEWVHIEMs0Xxa1Re6iw7z+u hX8w== 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=Jet5I/dxg9MkY22fUQ/+Md49LQv4nOXBFoSo9d9Ua34=; b=pOROYqzg3deMgqvOSR4j87z8LULv31hOjKjmKiUse4IyI9xImo2tO4zIuvg1JnRhvz vogUlaZk7vov5ggNGDp1EY+M55kbZbm3J2Jj7ybAbBYf3YpKzjsAMtRGxN+XLJdYVYh8 WHwUJ53mSdTJg1+rmFVANL4fOOJ6QhclTfx8ZaNbT9/NuEoCHsGBZmTnH2TUdEsJnMkK A4QovWOgk2wve23Rwh4M7H/yqeVhopzxveEHLgmqVdWB/ZFkbso3Y6QWq759IilxQ44p jxDmnWiqKyEgXJRvATeLqs3or/4SkQbOwOUMC2PkV56AUQmv7AYAKXPjnVDUw1sEBBx9 rPGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cz5wKtQE; 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 cw22si1376114ejb.705.2021.02.24.06.18.16; Wed, 24 Feb 2021 06:19:04 -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=cz5wKtQE; 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 S235900AbhBXOOq (ORCPT + 99 others); Wed, 24 Feb 2021 09:14:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:59338 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234502AbhBXNKf (ORCPT ); Wed, 24 Feb 2021 08:10:35 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 619B864F1D; Wed, 24 Feb 2021 12:55:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171316; bh=iBv5ViuTK+Xjuj/aIOqm3WuIkIabTmaz0NgoSaadXCk=; h=From:To:Cc:Subject:Date:From; b=cz5wKtQErV/1bKVL24cIoorkcG70vhlsRjokrN9QRMvs83PAbFHM58Ix17o/Gz7lI LLpBG6PI0IYcjnFb5uzh8JmyeVDZ7AQKfgG3L6IaCEC8FLbouuDJiCPrJon0rSWcM+ Z1Pd/xYUOsGrzmmy68KaGtM8EFf4LWrWNXtSSLDm3PettcLykITI8WpT98p3FXwu4r VecYxm8r3GVRKXjjutx7HXcG1nyxaJN5e0nvkuSSjUYPOVxATw3pp2NOybAz6XcTg/ Lbcz7QRRhYHLtsns2inHMYR603rHk84g893Neu6ohdOI+V5F/KJolsoWhS33Yjc1vU QbNlO2ACHVM6A== 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.14 01/16] staging: fwserial: Fix error handling in fwserial_create Date: Wed, 24 Feb 2021 07:54:58 -0500 Message-Id: <20210224125514.483935-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 41a49c8194e50..b19c46bd2557c 100644 --- a/drivers/staging/fwserial/fwserial.c +++ b/drivers/staging/fwserial/fwserial.c @@ -2249,6 +2249,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; } @@ -2331,6 +2332,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