Received: by 10.213.65.68 with SMTP id h4csp292288imn; Fri, 23 Mar 2018 04:54:53 -0700 (PDT) X-Google-Smtp-Source: AG47ELvgOr2KEB0c3+xfnWzcrZC1Lq3WO6AedkLdEZ4A8+/WdPPMI3oRDSE6Vz+9R4tgsC5HsNTo X-Received: by 10.98.6.133 with SMTP id 127mr23567785pfg.28.1521806093744; Fri, 23 Mar 2018 04:54:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521806093; cv=none; d=google.com; s=arc-20160816; b=oTHxnUJerY2yRyzZ5dRVW5F0uFuy1IOSXTdl6y65baHe7pcGNzP4tDN5U8TorewyV+ nL8riwZe55EtGrJp6AxHZeoQ53VD5vhcXNl3CdokeHG3QRTulhvSZWunL61SWhC2buh6 2x/29wrGsTbtR/hf8B0E77amDGExkH9P/gqIyviNzJN+0Rqp5JyhFs/QK1sMslXPpbXy SjKHEmSoM5KpVjAPvKDc9khXrjdFVdeRzvUQ6HIR7mkB72v2JfXHJhfuXXpIdNHEgwLB ZsNP6c9I25VC5E/fR/8447+VfcHhFtVEZFuD4PuPc2+uqpbuU0Wmp/lxD0vJUEpreEFQ jjmg== 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=RGxsYxVdyZYCKDDxPVIoh5aIUXAGyRxF5z1+aByyRgA=; b=xPZUDz4qeKwP+mLTG0Oyoc61S8pZCG+DgyEJETAR+yZe1YQLxAIkYft6ApZ4g3lN/N 4mxo4JArOdZA0t+VQUZWIq6ocQTFYmBq7abbwA+mLiBaxpuSRdKUMvSEB6Ku/BPRJj9v OueTxcYyTOe8bNEB13PpqNJhs0SsI+Z7He8bo180RQz57JqLzPeKSuMTOY2ikuM+nlc1 xglWrT+ucK/CVEPUH2F2qyLfdiOaPTwOCKnuCtsP6vlGgCgNqD1EQriCIBA9ZVpaf9El N4qrhZPNEJ5EY1BUn4bNSOEPv8LL1WUcKGaANUvHyVeTSjADHe40QRbwwGV1ZXyeWomu e2pQ== 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 g1si6085095pge.694.2018.03.23.04.54.39; Fri, 23 Mar 2018 04:54:53 -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 S1754176AbeCWLxh (ORCPT + 99 others); Fri, 23 Mar 2018 07:53:37 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:38044 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753974AbeCWKBm (ORCPT ); Fri, 23 Mar 2018 06:01:42 -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 338031294; Fri, 23 Mar 2018 10:01:42 +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.14 23/77] watchdog: Fix kref imbalance seen if handle_boot_enabled=0 Date: Fri, 23 Mar 2018 10:53:57 +0100 Message-Id: <20180323094143.750833773@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180323094142.260022880@linuxfoundation.org> References: <20180323094142.260022880@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.14-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 @@ -966,14 +966,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;