Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2708096pxj; Mon, 31 May 2021 08:45:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpXi4F1XiojcUQo7//T1JllyFu4K8qHrebzaC8Y81SuxlMzl+WxqH/k2zlPIdbfiImlg7w X-Received: by 2002:a02:ccd0:: with SMTP id k16mr8912310jaq.56.1622475929325; Mon, 31 May 2021 08:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622475929; cv=none; d=google.com; s=arc-20160816; b=l6bTvou2S0tuTdKCihLQkn5TUJiPocwwNIOc6Snapa2pfJPuUWBRrajMGSCdgKfHJa YP3qmZPYlCmI0FdxdQxUMQlR1T8usb1FDAXY5AqB0jk7RoOpbShsymSMxF9+J41+hSFn egbaWNq0Lupqu/Zirst3ydr5OaAaTdlhAvSOczW8eeDC2+eKDCscIIfOWIKXIjo9ttWc 7RarPFL4+3CL6122L/F5iu7TbEiaj+Qx6LSMdMkZYNOD+PknN4m0noKwsaKg0in//Vlo 4iQtuDNsJ3iEB/w7uYQwldQUXMzC+nIW2x2WvrT5rDdpZ2fgYad9P69SUdbnxml4gSEs OE8g== 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=1EH40br7qpMBb9iHg7sZdxnrZyrzxLY+dnbQnLMnQdA=; b=vrKZmgqY1RjRprz0Wmk93enYfMwB545KlchsNfrNA66jCVp6suHB23ITWipALvhVv2 Ivqe2AUFDgCStJYgjWKSnApfmhnHOvGGlmF5cILC/hFZbru16oWC88XVhRaW3N9sXbgg bkeks8Oo+3HMqac8cCDU4mmfypBDer+lSL0HG1V9Wx3cEOvFCByoZa09flbmYhlvrGah EwjOAQJhBqXvBO6xoOQV7IGl2VXwTa7aMiGaBNGLU5Nh+NVu1E+OPjU9GFOwGWRBmaQT 4KwxO5YsnfixxpuWHC/zGdASsaG89E+q40JaDDMt+h2MDbU5P2HzFHl622I/1XuHIuhh rIRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RldBNon3; 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 k14si14521394ilu.10.2021.05.31.08.45.15; Mon, 31 May 2021 08:45:29 -0700 (PDT) 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=RldBNon3; 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 S233397AbhEaPoH (ORCPT + 99 others); Mon, 31 May 2021 11:44:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:48836 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233084AbhEaOZF (ORCPT ); Mon, 31 May 2021 10:25:05 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6458F61A14; Mon, 31 May 2021 13:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468782; bh=b2hoTEC5uqobuuzMRsBFsNEWCV8ogZnhjo5R2n1ILIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RldBNon3oMsaov9tpB+TppmSkUKQuXe7cjuMzHvuVrSU1XsBZHGqxO6KWAKaRJrVF wD5/LBymxMqt8JTJg98cJYBQmWtKqzvlc94tDXZh9ePSzXoxHAvseYBwZ5Mgtw2CN5 WvuZAfNXTMhN2C6mjrVh1v5QDDaVmUZ9cowTMtWQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jiri Slaby , Atul Gopinathan , Sasha Levin Subject: [PATCH 5.4 091/177] serial: max310x: unregister uart driver in case of failure and abort Date: Mon, 31 May 2021 15:14:08 +0200 Message-Id: <20210531130651.038375111@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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: Atul Gopinathan [ Upstream commit 3890e3dea315f1a257d1b940a2a4e2fa16a7b095 ] The macro "spi_register_driver" invokes the function "__spi_register_driver()" which has a return type of int and can fail, returning a negative value in such a case. This is currently ignored and the init() function yields success even if the spi driver failed to register. Fix this by collecting the return value of "__spi_register_driver()" and also unregister the uart driver in case of failure. Cc: Jiri Slaby Signed-off-by: Atul Gopinathan Link: https://lore.kernel.org/r/20210503115736.2104747-12-gregkh@linuxfoundation.org Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/tty/serial/max310x.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/tty/serial/max310x.c b/drivers/tty/serial/max310x.c index f60b7b86d099..5bf8dd6198bb 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1527,10 +1527,12 @@ static int __init max310x_uart_init(void) return ret; #ifdef CONFIG_SPI_MASTER - spi_register_driver(&max310x_spi_driver); + ret = spi_register_driver(&max310x_spi_driver); + if (ret) + uart_unregister_driver(&max310x_uart); #endif - return 0; + return ret; } module_init(max310x_uart_init); -- 2.30.2