Received: by 10.213.65.68 with SMTP id h4csp309789imn; Fri, 23 Mar 2018 05:16:14 -0700 (PDT) X-Google-Smtp-Source: AG47ELvtu33cZvvT6J1ejkVD/NnPOtqNkNV1wn3QAseROkQI4sN+Cv1ECbHuyRip0CTeh811fDqe X-Received: by 10.99.95.144 with SMTP id t138mr20304551pgb.94.1521807374174; Fri, 23 Mar 2018 05:16:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521807374; cv=none; d=google.com; s=arc-20160816; b=gK8sCpz0yfFsZ1JRFP6vS5Hwb+s4Jt3J6H/hoWIY/ypEeOulhFHLrqLQrBJTzHHAJM 8y83EsEjRP7IJyanilaGJEUFhd+KDE9Tryvmunku4aDSDRFamZtSzwslGqabbHWm4M3q lmwWs9BsNLGZvrCh4tlFtwF0blVdQGdfzhdI+iJPqdzDZH/arR6QRUj4Mi1laij6BvEU hbftz+0WH/j3fbvxnccifFKvMMvWRFRH84UK/r+Zm933pj+aPYTb1ldzNen4H1g6c4JQ 0+UA+YriHY4LrvDfKKArVa/nfu2phD2drFNAlAZ7plfm+jVIX4mMxWEYEt3kAjhR5Lfj nY+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=c0hDAL8rNKhl/wl/LOuL9nWZQZO1Qg+xXkMen0iq/1Y=; b=V6Aio33jsAdJzXgbxdsrFPYxzmqPVs3AKaWwgjiP7D2k3duyNF3uNu2JqrL8zLntym SAmNve4kTwGJ89pqwKGBdTW0Wk3Ppm+rd81ftTbPtu5eZsw8Fx6itiDVUT+baj/rkjei 2HPfPjNlB4vgG5acNBn2OLMDzevVyKOOQB4aw96iiSe4aKSP7CCboJs3xM0ZWhx32JD1 mGMy0SPTq7ZwxwhPefEOW4smh/lL0oXbcIwNTwCzZqIUifOLtF7aoAbwHsAuJjcuXZ44 24+GURD1tDXBl+TUuUGg9lBOgieawU4vGhYe3pgU3zNExlP21yXlc225LdQz3YF5ZXSA lWcQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6-v6si8921516plk.489.2018.03.23.05.15.59; Fri, 23 Mar 2018 05:16:14 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752743AbeCWJ4y (ORCPT + 99 others); Fri, 23 Mar 2018 05:56:54 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34132 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752686AbeCWJ4w (ORCPT ); Fri, 23 Mar 2018 05:56:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B1D8F1056; Fri, 23 Mar 2018 09:56:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sebastian Reichel , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 4.15 27/84] watchdog: Fix kref imbalance seen if handle_boot_enabled=0 Date: Fri, 23 Mar 2018 10:53:41 +0100 Message-Id: <20180323095416.016623189@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323095411.913234798@linuxfoundation.org> References: <20180323095411.913234798@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Guenter Roeck [ Upstream commit 914d65f3f013ba2556c7beec5d3baac7b3292504 ] If handle_boot_enabled is set to 0, the watchdog driver module use counter will not be increased and kref_get() will not be called when registering the watchdog. Subsequently, on open, this does not happen either because the code believes that it was already done because the hardware watchdog is marked as running. We could introduce a state variable to indicate this state, but let's just increase the module use counter and call kref_get() unconditionally if the hardware watchdog is running when a driver is registering itself to keep the code simple. Fixes: 2501b015313fe ("watchdog: core: add option to avoid early ...") Cc: Sebastian Reichel Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/watchdog_dev.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -967,14 +967,13 @@ static int watchdog_cdev_register(struct * and schedule an immediate ping. */ if (watchdog_hw_running(wdd)) { - if (handle_boot_enabled) { - __module_get(wdd->ops->owner); - kref_get(&wd_data->kref); + __module_get(wdd->ops->owner); + kref_get(&wd_data->kref); + if (handle_boot_enabled) queue_delayed_work(watchdog_wq, &wd_data->work, 0); - } else { + else pr_info("watchdog%d running and kernel based pre-userspace handler disabled\n", - wdd->id); - } + wdd->id); } return 0;