Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2620318lqp; Mon, 25 Mar 2024 04:49:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUZblXZg6kuu/ccx9/L5C80VErQ/pruSL9a73vkjCPPg/wJiNFWnEqv71PbV+jc/9ZnpEtz2lbrvytg3nh9tL9C2Z0EoRAPk7NzK1ncWw== X-Google-Smtp-Source: AGHT+IEn4oBe4QLeRo5u4T6K9WtgKc+KFeaI9CRyisVtoJNMb58r5FPSSr0l4FVo87gnc8FE5nTh X-Received: by 2002:a05:620a:814:b0:78a:39c3:8bf2 with SMTP id s20-20020a05620a081400b0078a39c38bf2mr7507179qks.77.1711367354742; Mon, 25 Mar 2024 04:49:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711367354; cv=pass; d=google.com; s=arc-20160816; b=vqowyX+bCf6+AziEYgOlWcdgt2dCME9S5T1lGIb5GBmPdojSL+qnEhYK8duq1KAqK2 q5Hc1BzC8edTe9hkXsofeAQ2mpmOMRWKTu5AR5xggp0kXvTs8yVV1G11J7jUiRCcshGm TSK+bx2WgojsNI8A3OGxC3qAwJ/XH8ht4J4jfJUCJd9yhqVYZSyR8l0zFwKlYNuL+wfM XgY0FN0ERJnNXtR8BZ11ef7JPOXHjDjC0ykRwuble6Txix26nFiPD2X9Fb0+pzuu2hrx 7cAxedyOfAOApLutSrLEUIvqvyfVsemBg95LzM5YOgMkPS+i8Hvt0ISMKiI8xEhskM/p iaSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=ku5+Qq8h2nnXy/C8ylO42OrXURZbShqAHB26v/LOSpM=; fh=ZUYCNDtcXpadwvyFi2pWg1cNZIX8+4lN9QJ3+myKpTA=; b=PK4lvowgVx2XSyIlRIJ5x81X65zveym87L7M1rczflFVPblKed3Lii2Nwae9tyXzRK fytp3TD/wTX0VuNlNdCsnHwECz23h479hjgoEdQW7lrSzAZBhUfdVtDukN4YPb9iyyYP LzMNvkADXQ+y/PlI8QmBMzYQduX3FQCYDu4D7lqXZe6Ru9r8uKFWVQjF7WhRxkdBdnLr AHUEWW7YlTk7gt3lvJG15XqnNlyol5z5tJTLXrfPN9CBzQnzeANWZSuo7neD6IopcLDs HdyUTTgbVGmLTsrKFWaGGIL79Wgt3mTkB4payi+aOSConPEzFHWh4lJW8wQxTPDdn5O4 6aSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkM3RjX8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116220-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116220-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id z7-20020a05620a08c700b00789f31fb223si5164046qkz.356.2024.03.25.04.49.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 04:49:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116220-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=CkM3RjX8; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116220-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116220-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4BF6A1C35466 for ; Mon, 25 Mar 2024 11:49:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CE9C3BFFC7; Mon, 25 Mar 2024 03:34:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="CkM3RjX8" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B82E117DC37; Sun, 24 Mar 2024 23:44:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323849; cv=none; b=oSoxKOo34fAQ6XukNy653V4MFsalIoA2xrxX+/tE2IpdeS906yPAPRKQ6cJalxvnZlExY5zrNUZCyMqt/rRSLah+gio1ORenkL/m6Jw08xEqTeF5xmhr/e2umJ8jVLTuBSqN1BVio/V9fUIJr+hU21k/FZs8ObwenUifv1dVUDc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323849; c=relaxed/simple; bh=LDY0af1l0wOjYJ8cMrD88wlEhNgwaU1OcXBV2y4G9lw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZzYdfgHsGL1VLwlR66DlkxqVSvpurrZS/j/wQceNeSWcpHe6/MVa1thMHklOk2KflB0mR2BQH43SjwnU3RFNVtzunUxZPY2uWF3PwNB/MJGM980c5IhR33KU8qCkIYk2CnIfS6vWySZ2/jQq9Vi1aCPRnbOWlCzpKxZv4rdcKLE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=CkM3RjX8; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CAD54C433C7; Sun, 24 Mar 2024 23:44:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323849; bh=LDY0af1l0wOjYJ8cMrD88wlEhNgwaU1OcXBV2y4G9lw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CkM3RjX8ih+eN4aXSVuDpLm5f6ewtz3vlbbZOCuLsyfqLEaXgoEMVJCoDoOgHm71r oolHzrHMdvwbydK9UezMhSRC7LqIaTP6lsPv0exoIF485CEfD8pfF5batzA2CQlHtW QpFMQOwaZLK+y9qDCCWUvrdCOUMSYQrfP7TH3d5p6+xbNJURwr3muPvXZB2//si47w 0GaOBtEkMRfWOSKriLleuAT+qixzRePpoozabn/+iy9urk1HOAmjvEScWj1L8tFmn8 bTUtCo6ZM0GvBM4ItNUCkAf63dH5NRL/cKNbmV2LEsMh75hnOfyHzNHW4EmOMqcdft SafXnzH8O8oXw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Felix Maurer , Shigeru Yoshida , Breno Leitao , Paolo Abeni , Sasha Levin Subject: [PATCH 5.10 227/238] hsr: Handle failures in module init Date: Sun, 24 Mar 2024 19:40:15 -0400 Message-ID: <20240324234027.1354210-228-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Felix Maurer [ Upstream commit 3cf28cd492308e5f63ed00b29ea03ca016264376 ] A failure during registration of the netdev notifier was not handled at all. A failure during netlink initialization did not unregister the netdev notifier. Handle failures of netdev notifier registration and netlink initialization. Both functions should only return negative values on failure and thereby lead to the hsr module not being loaded. Fixes: f421436a591d ("net/hsr: Add support for the High-availability Seamless Redundancy protocol (HSRv0)") Signed-off-by: Felix Maurer Reviewed-by: Shigeru Yoshida Reviewed-by: Breno Leitao Link: https://lore.kernel.org/r/3ce097c15e3f7ace98fc7fd9bcbf299f092e63d1.1710504184.git.fmaurer@redhat.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/hsr/hsr_main.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c index 2fd1976e5b1c3..bea7f935f38e9 100644 --- a/net/hsr/hsr_main.c +++ b/net/hsr/hsr_main.c @@ -137,14 +137,21 @@ static struct notifier_block hsr_nb = { static int __init hsr_init(void) { - int res; + int err; BUILD_BUG_ON(sizeof(struct hsr_tag) != HSR_HLEN); - register_netdevice_notifier(&hsr_nb); - res = hsr_netlink_init(); + err = register_netdevice_notifier(&hsr_nb); + if (err) + return err; + + err = hsr_netlink_init(); + if (err) { + unregister_netdevice_notifier(&hsr_nb); + return err; + } - return res; + return 0; } static void __exit hsr_exit(void) -- 2.43.0