Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964946AbdIZFYM (ORCPT ); Tue, 26 Sep 2017 01:24:12 -0400 Received: from metis.ext.4.pengutronix.de ([92.198.50.35]:54451 "EHLO metis.ext.4.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753956AbdIZFYL (ORCPT ); Tue, 26 Sep 2017 01:24:11 -0400 Subject: Re: [PATCH 1/2] watchdog: Fix potential kref imbalance when opening watchdog To: Guenter Roeck , Wim Van Sebroeck Cc: Oleksij Rempel , Steffen Trumtrar , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org References: <1506356222-528-1-git-send-email-linux@roeck-us.net> From: Oleksij Rempel Message-ID: <7f1bad2d-0f82-ee66-e9d2-c67fbe38950a@pengutronix.de> Date: Tue, 26 Sep 2017 07:24:10 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1506356222-528-1-git-send-email-linux@roeck-us.net> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 2001:67c:670:100:5972:3060:f674:c7e9 X-SA-Exim-Mail-From: ore@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 619 Lines: 10 On 25.09.2017 18:17, Guenter Roeck wrote: > If a watchdog driver's open function sets WDOG_HW_RUNNING with the > expectation that the watchdog can not be stopped, but then stops the > watchdog anyway in its stop function, kref_get() wil not be called in > watchdog_open(). If the watchdog then stops on close, WDOG_HW_RUNNING > will be cleared and kref_put() will be called, causing a kref imbalance. > As result the character device data structure will be released, which in > turn will cause the system to crash on the next call to watchdog_open(). Ach, ok. I see. So the stop patch should remove it from the start.