Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2627579pxj; Mon, 31 May 2021 06:55:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1Hd/mT9uQkqpQdw/5+NNqyiw08pugxd1goyLdVUn/vC75GUOdLg/Fl3wre/830xxaYGzX X-Received: by 2002:a5d:94d5:: with SMTP id y21mr17232395ior.110.1622469319372; Mon, 31 May 2021 06:55:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622469319; cv=none; d=google.com; s=arc-20160816; b=Qq2aUnIvnA7pqtt46eeUI8v3yD7zoCcRQmiVJgIhPmofn6PNqcTEJy1154PcAMklYy rAaFC43o9fs2si7MFcJzelMlgePCpkKmgIAdwXdisVtI5v/jUWC+22lnxAUqF021Qfe1 KBYJ7Jpkg/RVtgqTGAguXa5+LXG4FEP5d3hEpJ56tKs+zqMSMdLzEx2f10jffnUvoU6g 3C4ak+4LdbRKw2kdGNpEFSG91TDJDUigWu0u3KGaNvYnHvN6lJavm9YP6mq3dRykquLf HIuWQ0IIat/LMt1BRVmTpbHdHxG1AifsxXckSh0/NicYSYMTAc8gygUAvJWthJrfqClG XqrA== 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=P0RW22k0iAE88HwDXuqJ3Lg1HXOBS5p0Tkx+DCotWY4=; b=pL8EwQboI4MqEER8xSruR0AQHGsJN+0WqdKHDtB8DzzVnAg0JAuKpJeWk3ocaw2vM4 VadnRYi9U2mhClHN2oZ/2uhPXUNM+gNEPYeX5Ndommn3bfzH2aF9k/ZyrG7/lZ5w6V2S uUzTNB+WGbJIM98TpInvxEHRXiZHq87dHfPBYdNth8VjyGfIsCovWX0OEBdSbnk+qR11 nsNvDSe8nTkDMdnhG1bHJ2Cw3tjSQTSfKOT30nTgeIh3zFrCUi0zO0h5HoCxbIILd8mk MhSLWrxjUjiUbedhDXKXAd9JpUtSx1fnUtRoQvHT06+CRmbeyL++bTygUaJcRK7cdd2D qUzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=VDn4iLvH; 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.06.55.06; Mon, 31 May 2021 06:55:19 -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=VDn4iLvH; 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 S231695AbhEaNzs (ORCPT + 99 others); Mon, 31 May 2021 09:55:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:43906 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232532AbhEaNhJ (ORCPT ); Mon, 31 May 2021 09:37:09 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 580A86144F; Mon, 31 May 2021 13:26:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467560; bh=mJeqKre+1wmJpQ/4NRYPtBLkivBvz8xppH54EUsGy8s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VDn4iLvH5ru132p5zBc0DLKWICgtbAglrE7dVrpVHowtgVbXTdkN9xd29riv/e0XJ GoB3THIFErtHmCfMPxSrP4DhplFkntRZPPm7oGHmPCsnP7/eWK8cTe3nGM85LXHydx CpIiFmat2A8SSipS7vphCUtaFTgGSja9fmp1O+5I= 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.19 076/116] serial: max310x: unregister uart driver in case of failure and abort Date: Mon, 31 May 2021 15:14:12 +0200 Message-Id: <20210531130642.735432583@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130640.131924542@linuxfoundation.org> References: <20210531130640.131924542@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 0c35c3c5e373..c1ab0dbda8a9 100644 --- a/drivers/tty/serial/max310x.c +++ b/drivers/tty/serial/max310x.c @@ -1480,10 +1480,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