Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2664189pxj; Mon, 31 May 2021 07:44:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmfy+S5mruabTk4qB77G2kJX8TlR72tykHo33lcEnS9LLSaDpGBdcMD3NlZ4a6WgRAtPJ8 X-Received: by 2002:a17:907:2059:: with SMTP id pg25mr7980026ejb.130.1622472285303; Mon, 31 May 2021 07:44:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472285; cv=none; d=google.com; s=arc-20160816; b=wLjyi7fUl5JX/Y+MdpVBypzyR9sU/DMGgWs9WqZIlgCb7owbVjdvJ+u051/MCegiQZ 3Qpor/am+nCBlQ1/YKQtqzR+z6GjL8ldB70W7sYufNbzc0UMO9vsF+DDaIGaxQYsHaCW TdlVITqqlCA4z6saujxWdVTU6eMP0v4Wz7h+gKz4FJKWbYk/U0YI7OUQyHqG3PxV9iY/ Il/sBEmOglL02M+g1xHR9R5k/xi2p6mMgww1lgtTkcF2aHLDDu7T2sN1MXsAbTudnoyL ZEG0irr+X6wCmrYwLYrqqOHmHGGnpiEPXmn80vMdqrTV3on4UkT+t743UsP+M2GvKENm 92BQ== 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=pzWRIwZKgLWi3K4kTQ6uY6CR3pMN7Lf7Lt24SDnc5x/HacEYo9usinLwKZglORvhZN l/J/FkVFlW+RNaqAaaJgZLjKJZeIUpZF6SApqzHkSnggqnFmMdRk2O5YuVBtKyCQbZDN ggn955RGGEtdBRlK5bCZKreokfkJfN+eo1tWQbzGkm+ibXxDlrKas4jvM3NGV/Y5ujuD mwChjRvF8xe55GsbQpK4PZ9RRLv/TrPnCswYz0+tNDjTFc4NpL5GirxcB/0DEpVI/Ecr ypRkMG/tSREVp+kaR21deI427kYgBzIctPZ3bRXgxUJYPINjV9w4ReOFpQbxDHcxzRSU Hb2w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EwgvvK5n; 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 y21si12331206edc.43.2021.05.31.07.44.22; Mon, 31 May 2021 07:44:45 -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=EwgvvK5n; 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 S234116AbhEaOog (ORCPT + 99 others); Mon, 31 May 2021 10:44:36 -0400 Received: from mail.kernel.org ([198.145.29.99]:59814 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233027AbhEaN7U (ORCPT ); Mon, 31 May 2021 09:59:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B8C9B61443; Mon, 31 May 2021 13:35:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468155; bh=b2hoTEC5uqobuuzMRsBFsNEWCV8ogZnhjo5R2n1ILIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EwgvvK5nSLj2d16aB/L3L3HCj/xs//oJ+Xx/Nsw2JfEAQ+JvOGMMhbVTaOhkWY1r9 ihhQ+xdAJBcupfTqkfKOBFe9ieSuGDokrJJ3CqJ083yDtJN6N0gfbyi+hxEqezVdbg EBGmQN6hj1HyELbMXr91bVyZaLs/etnz/uFhCZPo= 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.10 136/252] serial: max310x: unregister uart driver in case of failure and abort Date: Mon, 31 May 2021 15:13:21 +0200 Message-Id: <20210531130702.635838545@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@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