Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp415249pxb; Wed, 24 Feb 2021 05:48:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJytUX8z5Sj7Oa8yRa36WsKCcsfaQN+C6FAGd9L40bA6LSvK3PwV5TW6KmOF7DcJqJdM10qE X-Received: by 2002:a17:907:1629:: with SMTP id hb41mr30168815ejc.197.1614174519554; Wed, 24 Feb 2021 05:48:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614174519; cv=none; d=google.com; s=arc-20160816; b=jZw/ec9QWmm16/LL2yHVLzgRFD7D+aG4LOjdAQq5514w5/F/R3stDZsNuOnNjQh4pW QpbxRoKBOJ49TKfgvxAN4dYGotkvrbusL4SfPD4wPD29YG049Q4MYYsa3G4zpH/hDgtt o5B7ZhqRLmAndGJGnROGo+82SbOcWZad+Xe3bLhmoZjvpUatIYIt6BuHZEYKOowA+8bD bTokK521jopzJATlqPMu8tddcj5fsoWrScx27IMqdLFs+XrYGflvVOLAFfrltmMWFYDj Fr7N6cokkn3mdyOcJfGGFKa7gccZSmzvO9gHYC5lJkZKDOZSWwzETfCW7BZXrwwQZCXy YwXw== 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=1lWk3LVL4kN2rrr+hmix79lqRhONMAKdBXaAF9PaCUY=; b=P5kZwIC6ttjUcn8huLdLZlpKBHr1KAqE9KDWFt2M5QRKjPahGm1lRgXgGt1ctQURd8 GNsqhFyv+K/L2ndAs+VdDjuMFsOmJdViSNk+6K707Sw2T5CkEfXe/tXDqKgY0LhgylYE WRZhOJrdfV0t6IVOjug5i+3kjXPIsaMpShu2e3bfzg+puY4Z5Olws9aCTWNcocrpq0tC 7KrMxahgQAhyfNowctJgKtlNwKgJ+asbdNHZbpvyUhoBrB7QQOs7x6sCCWkCD4wtB2kZ flUhSiCmHgkYdKwsETXyUCaBBMCCS6bG0mn4m9iAi0PHHTdCBUCI1P9azgUaLk9XO41T QDeA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JphrkeRD; 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 t29si1240603edt.211.2021.02.24.05.48.14; Wed, 24 Feb 2021 05:48:39 -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=JphrkeRD; 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 S237444AbhBXNkr (ORCPT + 99 others); Wed, 24 Feb 2021 08:40:47 -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 S235221AbhBXNDo (ORCPT ); Wed, 24 Feb 2021 08:03:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A8FF164F5A; Wed, 24 Feb 2021 12:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171222; bh=p+lxkQWic3CI9G0twMBf/txJ+MWfriResU2klUeS94A=; h=From:To:Cc:Subject:Date:From; b=JphrkeRDpqQcxN4OJuXGIpzlmEqWCsV5SjPGgOHeG+kYZWsdGPJU6DWtDI4rMpDLP bLPUP88A/5MV6DefdHvr6Hc1oVuqNa9lgAUU68Iyu/LhTl0aMSEdr5Javej2ozZc6a Jmx5q8I69RPlaWMDtphEJvEtjai0VUNCiDLLSuz6fCS3NOCSpYVYmg4OotSGxpPItP ulcQ9te4OTAKgmc4URWCea8HtkzNo/i36swdFF2ihOLkPh0lUKSfzRag5lXmZxt0Qi jU0EJvyyHwun4nZjH1IbGOv2WFGGwLqZGM5xZqj2oo9QkDfzKZ99fXuyuLbYLnbRuV 7N8BQMA2klfjQ== 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 5.4 01/40] staging: fwserial: Fix error handling in fwserial_create Date: Wed, 24 Feb 2021 07:53:01 -0500 Message-Id: <20210224125340.483162-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 aec0f19597a94..4df6e3c1ea96c 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 @@ 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