Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2636880pxj; Mon, 31 May 2021 07:06:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxZdIKdGlpZGk0NCzjG5a5CgTnFtNMYw3RMNY9rGRxzvX1R58jIGnnoU8SrRkjtsJRqq4Uu X-Received: by 2002:a05:6638:2728:: with SMTP id m40mr20871302jav.55.1622469996527; Mon, 31 May 2021 07:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469996; cv=none; d=google.com; s=arc-20160816; b=BVBoNfu10HIJi4JNg31bq1tLfhh02l1csNSizrVX90Rj98VxeMsXgQByqv2uTk7SJO 2NuYqFrQVTBIL2DPvugK5NN40v7RClB2a/FtoCKSNN0TWShwravovrWC1Y5Z8x+lot+6 DWsufVjuKjB2z40I86RTYD5b+WRV3ZLRCO0ZE0Ib8evrvQLRSkVKNDFbSndRQWoR6ZGf AwbdXre0PWnFfVCz/LTf2Gst1vyTjbfy0EoBRVFFzpNntddl8Gsf/Rdhbl5OSPCgwS3P S7dyuDN9wuwRP95Sm6cEvbU7kenTWxGUl5b4YO77rv74xEP+64IN9Bz/bEWF6d7jJVac Wstw== 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=AmdSavUDlYw45rVzXic+3Mugng1iWaxGm4uU+toGt9U=; b=iAx3r2tXEmzQO7pLz8Y0VsD4x2BrP90q1SMtYpYdsxmtwpwecMMWWw2/rFg8rAcKax TCID1QzndEu2jWnJtKVRfM15Dxhab1Wh32r4JL9YzwJ820eXt9QHMKkmU20ubxz5bRsh D54YsF/KuyriyKa3LeNcnNoerKXLduC0GQ8K6iKsDqv2YvtmIleoPy2PY6itzYjOA7Ll 4Pi+rf0VhMeKovvyBA+Cs/4ujmCqZ17ZvDKiRaGCLVCuaZkswF/uQvMnNUMG4svK3jmJ UOT3o3SBqLl7jEFdvMowjc+biSpmoXfGEMGkMHUQshEQUTy0GMoPUVjvoR5n8rMRjJCt c74A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zcihPXPw; 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 t2si10522586ilo.160.2021.05.31.07.06.23; Mon, 31 May 2021 07:06:36 -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=zcihPXPw; 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 S232614AbhEaOFf (ORCPT + 99 others); Mon, 31 May 2021 10:05:35 -0400 Received: from mail.kernel.org ([198.145.29.99]:44426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231899AbhEaNlt (ORCPT ); Mon, 31 May 2021 09:41:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C517D61376; Mon, 31 May 2021 13:28:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467695; bh=LSLv/cJ9GS5P3FoW2ST1fAGpkDOzWEU4nAYcEnOYDJw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zcihPXPwhZGzFU1uETAZNSl5I+U0nlDDHIEWOa3QboWjw6BSLbpzi6swaC1fGKBo5 I8w+odNRqRv7JyVYQm7Nw4KSkO/iilPPXpPBJjkc0gUD6cgq2fkKt3K1p1KtqxQY6n ryvBnUZjBcK0DU3AzHZFPqngs+2mFD6i6uFnPs/Y= 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 4.14 46/79] serial: max310x: unregister uart driver in case of failure and abort Date: Mon, 31 May 2021 15:14:31 +0200 Message-Id: <20210531130637.487651699@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@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 cec995ec11ea..454659544d35 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1385,10 +1385,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