Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp2696603pxy; Mon, 3 May 2021 06:09:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWFoN2fBlN9bkK2epW1yB4Y1FzGYvQ245Hu2oQkls3Gt2luOZorKWtGjZR5A7hRvrS92Ky X-Received: by 2002:a17:902:bd41:b029:e6:933a:f3ef with SMTP id b1-20020a170902bd41b02900e6933af3efmr20530715plx.19.1620047361755; Mon, 03 May 2021 06:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620047361; cv=none; d=google.com; s=arc-20160816; b=WV9H0N1vKMI6aa/y8OtFMVMQIUWGdPVquPpFYN1NvwtpfHv6Zn2R/cfNsxoR7hEZi8 qLhzGyljb44iu53aTKJg8p6b38E3SgdZcLCKz54go55jVPfZajV9o1gaUyxRK871QDdc 0fNy7JJrSyc9wTuoWoE4Do+874FQSBPU27MnhFyJeHNQLiX9LDlE1+N4LpdoU/zGcauR d+7KehYc3ng2mHwPnV58sBGIFgwg4T+Y/XvkVwdsgYyQ1jTKj5I3n02rwrYwMGQR/6zM +vHRDggAbCdnXpSi0dxGZCy+YqjaPnweXvOFeZ78T7GfSA2RvuZEPpgd64vp2fwWWwsN zI7Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=F++GVvLoctalStVYnDgmmeAUgZcCGD5visaodhAONk4=; b=mZOygHgeavqmMcyRN4jw+BYz2DeBMD86TlB/MkDg/Lw9ZtLXM8IZvvexOmiikiU8uO 1nmKfySKAvypBl0qBD7JJDSdLf9lkhUWoCxKgzPIvPFN/kO8Gd+P2QfiHb8aAPbvBzh6 mCI9+xcX7XXnqTjcvsGawcmGaTxMR/3xQpfdRjUP6WF2ZByTneL3l1nLdiYUQvF4Xp1c P9qbzkemLKPvI4oAqVzM288nhoL8UfSqjE/l484sBNyfzvpPPds7ab82C7fgsSlwGY+9 Y/LI7GV1Qpwnc1eONFO29uoKkJqb0oznAlcE2JKDcBYh10FmUYK7QbGZNV1yYH1DopJJ P1vA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="P/ITEiLT"; 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 b4si14877029pgw.419.2021.05.03.06.09.00; Mon, 03 May 2021 06:09:21 -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="P/ITEiLT"; 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 S233820AbhECMBq (ORCPT + 99 others); Mon, 3 May 2021 08:01:46 -0400 Received: from mail.kernel.org ([198.145.29.99]:35614 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233870AbhECMBC (ORCPT ); Mon, 3 May 2021 08:01:02 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B41C061363; Mon, 3 May 2021 12:00:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620043208; bh=MT2AvRavQJ/I4HrFXTLKARGXGKgehxLNJtxtTCaBlG8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P/ITEiLTSVn3bcq6B6gSvdS6UBT8vKHOQHqpyY5oK4pBILciMPbHi2iTBtkq9JyvU vlKWJaFzqkOraoiC8QszJnT2I7E7XK3VfCE4cfUb6zuDOg13qprC8vzVnxyCWuEtWh d5kGMFANXCgZ6gSS9/AlbNDF5XrxEbyIWoDcJGkY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Atul Gopinathan , Jiri Slaby , Greg Kroah-Hartman Subject: [PATCH 11/69] serial: max310x: unregister uart driver in case of failure and abort Date: Mon, 3 May 2021 13:56:38 +0200 Message-Id: <20210503115736.2104747-12-gregkh@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210503115736.2104747-1-gregkh@linuxfoundation.org> References: <20210503115736.2104747-1-gregkh@linuxfoundation.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Atul Gopinathan 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 Signed-off-by: Greg Kroah-Hartman --- 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 a3ba0e6520a1..3cbc757d7be7 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1518,10 +1518,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.31.1