Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3096394ybi; Thu, 18 Jul 2019 20:57:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqyAPDeNLAI1DOTK8QYRA1n5QSdg9dAtHyOOdg65Yax+oYx/QUNEtuXYbjq9AFLTRQusjPEi X-Received: by 2002:a17:90b:8cd:: with SMTP id ds13mr52345092pjb.141.1563508678405; Thu, 18 Jul 2019 20:57:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508678; cv=none; d=google.com; s=arc-20160816; b=rauAvUil77HBp++7uJKmVosxNqi3IeEBOyDi4NBwkzt0IJpzfZw4ALv0kSVvzeU0b4 mS7kfkCSGQBcow72iojgt80JVY7LPCwCmkB7evdLyt4s07tSTfsTdcNkHKKBwh4YMXYK aFwRuKPojXW25/Yf9d8XkRlSWbOh7a4P/KyuNHNoLgdBsiVC8qHWq/OCCesuC30g0CET 51+l63ra8Aoa5oZCROMP8RpRA4+fKlaoaM3XaSqh9j4WDU2ZtrCB0PvCVZa2Kpxi8/DC e+tlFZGSqA3nvmMHNjsRXVbAT7/i5Bybq2GX8h3fFiFXC9xUmUIeGA7mNAg4ZA2GyuzU TGXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uTDZiriOzK/OKPM+/0554eGT3u46z601EnkGKoNT16E=; b=bkadpkqsZzLHWkdWaj80xcrShDpCMCjHHVAw+T6l/baAKyxwgaz7UKAGWHme9dsGpn 5X36xA0S/9qu3Fp8fOn7UEU8ZsVriAWyUIKJZuHPInGdWqHkad5z0l5K9rxv3nrnY7z+ UzMdFY2C7Z6JryBQGMbdn2B5Enw95eMos4XFnVT/HIUc8OF4qkpyWLS82RekPiniwj63 U2JBtelOjtvRsQR/jhwMIbRjYxT1T+DUtKVbWtfnMcrn2XzWE7tj3wKa3/fhs6Pvljgg VHLBeEc43+lt4a13vvBATZAhWWXD9YS/MF/CdFJHp3qrB5aA1muio4qx9Ctga1O3pIkP 0teA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2D9VwyOW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i188si946287pfe.96.2019.07.18.20.57.43; Thu, 18 Jul 2019 20:57:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=2D9VwyOW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727018AbfGSD5I (ORCPT + 99 others); Thu, 18 Jul 2019 23:57:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:56332 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726941AbfGSD5D (ORCPT ); Thu, 18 Jul 2019 23:57:03 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 900062184E; Fri, 19 Jul 2019 03:57:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508622; bh=0x+K6BU4fDjllyEo+Yimd2GVCgLa5ENbGONnnLzPI4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2D9VwyOWl47q1u0Kjv4dSRZ7izeV395Vq55rBFY2YMN9zIWytlDa+5BVrfutuH8yO Gp/t1ffXQ4D3SYkmRty1Z1dETF4fRaVWdGhnPRgMylOp+mzT/Krt18ar1JST30khHP ekFbaVf8gM9eJd7AUWDZ2a/OzCtr7h058ehvjeec= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kefeng Wang , Hulk Robot , Corey Minyard , Sasha Levin Subject: [PATCH AUTOSEL 5.2 007/171] ipmi_si: fix unexpected driver unregister warning Date: Thu, 18 Jul 2019 23:53:58 -0400 Message-Id: <20190719035643.14300-7-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190719035643.14300-1-sashal@kernel.org> References: <20190719035643.14300-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kefeng Wang [ Upstream commit 2f66353963043e1d8dfacfbdf509acc5d3be7698 ] If ipmi_si_platform_init()->platform_driver_register() fails, platform_driver_unregister() called unconditionally will trigger following warning, ipmi_platform: Unable to register driver: -12 ------------[ cut here ]------------ Unexpected driver unregister! WARNING: CPU: 1 PID: 7210 at drivers/base/driver.c:193 driver_unregister+0x60/0x70 drivers/base/driver.c:193 Fix it by adding platform_registered variable, only unregister platform driver when it is already successfully registered. Reported-by: Hulk Robot Signed-off-by: Kefeng Wang Message-Id: <20190517101245.4341-1-wangkefeng.wang@huawei.com> Signed-off-by: Corey Minyard Signed-off-by: Sasha Levin --- drivers/char/ipmi/ipmi_si_platform.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c index f2a91c4d8cab..0cd849675d99 100644 --- a/drivers/char/ipmi/ipmi_si_platform.c +++ b/drivers/char/ipmi/ipmi_si_platform.c @@ -19,6 +19,7 @@ #include "ipmi_si.h" #include "ipmi_dmi.h" +static bool platform_registered; static bool si_tryplatform = true; #ifdef CONFIG_ACPI static bool si_tryacpi = true; @@ -469,9 +470,12 @@ void ipmi_si_platform_init(void) int rv = platform_driver_register(&ipmi_platform_driver); if (rv) pr_err("Unable to register driver: %d\n", rv); + else + platform_registered = true; } void ipmi_si_platform_shutdown(void) { - platform_driver_unregister(&ipmi_platform_driver); + if (platform_registered) + platform_driver_unregister(&ipmi_platform_driver); } -- 2.20.1