Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3097195ybi; Thu, 18 Jul 2019 20:59:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqwI1p8oYALidveE9pVxd+PcVTdkHs3ryBm56raGcKaxhM67Eo520A3cvJGq5KdWqa+e+6yJ X-Received: by 2002:a65:4489:: with SMTP id l9mr53153836pgq.207.1563508742751; Thu, 18 Jul 2019 20:59:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563508742; cv=none; d=google.com; s=arc-20160816; b=qab7EnYOGXAf8dABfLMwOARBPnKeb2Fg86ASYYlIPfevzymFy6myTIvZrXDjRTxHTo L8bY4uvuh8QSOR/k0nqbah+bAdfRr5iBkx80ieh1JtI2iPyXJqaaxliHi5csuHuaSJdt qK+slYUV4OSZAWPlrrd1bFlPL8blctMQB19ASF/I98fN+TbJaBEkvUXzeU8rcY+uaWVI lF7+Ra01O67WJqac8+koQnbLUEXidVANSBvIzp8EGmQeAqGaXXMrbF6a9+BxZYsM5cyI UV4Jg2phmZEkLvn2TOwLFChNNwkYL9+H8sPBoIWT39Ec+MSgD4ZoThAQKXjPkNirEGjE nnJA== 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=IIT/RtYGZZws4XtFnXdzCyZqHPe56h7eCzu/Kr8Yv4M=; b=OM75ngrujard+qq6xVRdGjg3Rwuo69A9lykJFO/6N822J+3Dh+1CeAtp6ebt9yBX+2 PW7lsK7/Xze0jBypwpaewHstRfxbHJAZULHR3ejAmzkY7oASIbc8V+D1G6hCdWS3/9hr cX29Zt8ced6j38yWpzrnGKlnKRBh0//mjL/30Y7u2seIdqVpyvIfnU8E34jlqwlbXavC nUDvTA8Hgaz0fP2ZQ7EC+2EBIKHuPY3uN2lg6Wca9vGf/8hhdz5gDg3tr7NBkHSzQK+/ n3rVlzfqw6TDfdk3hCYrPnzRygcjciBC6LLj3ggX1Ks7MYD0+XFwXJKkooC/+1z5k1q+ Lg7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="j/AGhMYf"; 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 f1si238199plf.410.2019.07.18.20.58.47; Thu, 18 Jul 2019 20:59:02 -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="j/AGhMYf"; 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 S1727330AbfGSD52 (ORCPT + 99 others); Thu, 18 Jul 2019 23:57:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:56668 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727279AbfGSD5Z (ORCPT ); Thu, 18 Jul 2019 23:57:25 -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 4677E21852; Fri, 19 Jul 2019 03:57:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1563508644; bh=Wo4zMwNeFCaCiuVGaxn4quODQXtKSbgms1sZcupcT7I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=j/AGhMYfRBeIZ9HLIa7H1A8MczZap6XzQqsdxUp3Or7xVAaJgri5RWxKNAjdfuYqL oYedsjMiQcPYpc7nz9+SRpxmyyjc53TtxsRBvZ52EtUIpdX2K+/XTsqF5rZ74RIUlQ XS4UxUWjuQpSyYU76Dsfaq/XmJFtLZ2bz8SwyEJY= 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 017/171] ipmi_ssif: fix unexpected driver unregister warning Date: Thu, 18 Jul 2019 23:54:08 -0400 Message-Id: <20190719035643.14300-17-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 2cd0e54489e65b8e22124a8b053aff40815487f7 ] If platform_driver_register() fails from init_ipmi_ssif(), platform_driver_unregister() called unconditionally will trigger following warning, ipmi_ssif: Unable to register driver: -12 ------------[ cut here ]------------ Unexpected driver unregister! WARNING: CPU: 1 PID: 6305 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: <20190524143724.43218-1-wangkefeng.wang@huawei.com> Signed-off-by: Corey Minyard Signed-off-by: Sasha Levin --- drivers/char/ipmi/ipmi_ssif.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index cf8156d6bc07..305fa5054274 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -303,6 +303,7 @@ struct ssif_info { ((unsigned int) atomic_read(&(ssif)->stats[SSIF_STAT_ ## stat])) static bool initialized; +static bool platform_registered; static void return_hosed_msg(struct ssif_info *ssif_info, struct ipmi_smi_msg *msg); @@ -2088,6 +2089,8 @@ static int init_ipmi_ssif(void) rv = platform_driver_register(&ipmi_driver); if (rv) pr_err("Unable to register driver: %d\n", rv); + else + platform_registered = true; } ssif_i2c_driver.address_list = ssif_address_list(); @@ -2111,7 +2114,7 @@ static void cleanup_ipmi_ssif(void) kfree(ssif_i2c_driver.address_list); - if (ssif_trydmi) + if (ssif_trydmi && platform_registered) platform_driver_unregister(&ipmi_driver); free_ssif_clients(); -- 2.20.1