Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5576315pxj; Wed, 23 Jun 2021 04:32:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy30A4vfrXK0WfezmlxVR01CYi7yqdwrrhkaYdhrPxtR6KC3DRX9NHukngghBTTEHf0vMfP X-Received: by 2002:a02:cc52:: with SMTP id i18mr8609867jaq.47.1624447970188; Wed, 23 Jun 2021 04:32:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624447970; cv=none; d=google.com; s=arc-20160816; b=lMeLeh2bnBmH3M216g/dQc0apa60jOvhBAnERulX/+H82EFy3u1KNlVSBtGtkTQSru nBIsX/UyNTWE5ygP2IoXYkeXenDsa33acnffejmDs0f/s4PlBi+FNHE5ZPSSQYU48huu KjeThGILs6dnDZeBxm9FcNTWvZuroLSM2Vc8di0mTLUE064P9tJowdKnf9tcsGCBKY5/ A2fdqUxLnwm4sC5I+nAZ9UuRlr8JNJWcf9KPlfKjRNY8w9t/3lxv+NnkLmyiUTQXcNke 2asxv4qk2h8TIOMh40uStr71eCsAvSerHVW6uIyt804lMYbsjH82hQJGoDki+ZZIlxvC u/eQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=bv2OIE88drJYx54rPZawJzllQ5seF6RUH1fKOPSuZ1k=; b=UQ9Oeb5tc/6pOEtpgMWNpzqfifUVIGcY+RlgQ8gOKnAqPb7SgU4vCYepY2DbU+Iy42 gx+gDKbmmuKU6pRQubZ94LWJJYH6trjocT7dE3tEIGABCnME97RFpfikxD0XpZ8x9zKZ R9m+TgZ4V4vQFyvOsFloBLpW8uquIiL+Aci6dQrD8wbkhDsJxkFEpuQ9mDOc95MBj/4C ktUXnXeug2lb9jR2FZpRMD1ZBywMRp+LU86WSnTCvXp0gW5VB81YpoTvGM+SXQl79qE0 En4BLVZ0pqyrPe3w/8LhSxs9kwgYnHijz7Cn2vjisShjlYScTHi5iW3OyGgHQ5H/lLaZ WAaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="quZT8TN/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e14si2602849jaq.1.2021.06.23.04.32.38; Wed, 23 Jun 2021 04:32:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="quZT8TN/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230138AbhFWLeH (ORCPT + 99 others); Wed, 23 Jun 2021 07:34:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47208 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbhFWLeG (ORCPT ); Wed, 23 Jun 2021 07:34:06 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86F78C061574; Wed, 23 Jun 2021 04:31:49 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id n99-20020a9d206c0000b029045d4f996e62so1598749ota.4; Wed, 23 Jun 2021 04:31:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=bv2OIE88drJYx54rPZawJzllQ5seF6RUH1fKOPSuZ1k=; b=quZT8TN/B1px2LDz44aKHxqTlqdZsT0YcyKFJ9Mt2u1YrxVzQB9GHaI102LbMV9Uv6 EMar4xkHFJQv/FDoiFqSh5U7k7nAGO8AfyEJAg/7KoJbpotJZmNMX68ooDCv+XGCvw2p mGfcdD1d90Za0NkPrmvgQYqpSu3RKkCkPy0Jw1BG3jd83OX34RDBq1/PmRSiiz98uoZD /OIyPwZxqau4cBrywhIc/7P/jt8KDA5hy41pXfB5mzSE0PTBv8qli5AmJgG0ryVsePd1 1ueVs/8T3GhihjnwasqUmb/GFU7HKP/wNCLL7qQ9MGdJb231ahRNU2X++S2ieTpSgdjL ttSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=bv2OIE88drJYx54rPZawJzllQ5seF6RUH1fKOPSuZ1k=; b=P96g1ZmP0GMY2y5uf9Kx5hRe6y1fJVXuhXMQeP3b1pa4m7RoEX9K/9CqeSpR/RooEH vE3/xqr0vHIuBSxXTL/4Nv9C0huvRcCLfhNMaX9+tBpmgrHG4A2m23B26xnmLs2aPmoz VvzvA7H055Id6bAUaxsSik9DWjkeaUf8nTn/VJGPM9XH51GW4DaTpeIRim/bu8lrESqG JuPf2dFhT+Ho00jjJtf+fG1qXEnU2n971XTXnd17cxy2dUcFlQb1yd1h5wwB9sRlqdcS 2aeyx2w9aFDiY0T4a9KyyneivE2vfYPFl6o8KP03QKkPhUqKnjC7QdoV+rU7cv6y4rj/ LFXg== X-Gm-Message-State: AOAM530ZfImmzbxz0uEoSZ+Btz0NX/6sYTxQHDVU1QOCSRFF+2OqQQwC C9Iq/szRexIBzeKFVe/WNo4= X-Received: by 2002:a9d:2cf:: with SMTP id 73mr7381852otl.314.1624447908980; Wed, 23 Jun 2021 04:31:48 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id x29sm510858ott.68.2021.06.23.04.31.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Jun 2021 04:31:48 -0700 (PDT) Sender: Guenter Roeck Date: Wed, 23 Jun 2021 04:31:46 -0700 From: Guenter Roeck To: Curtis Klein Cc: wim@linux-watchdog.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] watchdog: Fix NULL pointer dereference when releasing cdev Message-ID: <20210623113146.GA1316730@roeck-us.net> References: <1624429583-5720-1-git-send-email-curtis.klein@hpe.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1624429583-5720-1-git-send-email-curtis.klein@hpe.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 22, 2021 at 11:26:23PM -0700, Curtis Klein wrote: > watchdog_hrtimer_pretimeout_stop needs the watchdog device to have a > valid pointer to the watchdog core data to stop the pretimeout hrtimer. > Therefore it needs to be called before the pointers are cleared in > watchdog_cdev_unregister. > > Fixes: 7b7d2fdc8c3e ("watchdog: Add hrtimer-based pretimeout feature") > Reported-by: Colin Ian King > Signed-off-by: Curtis Klein Reviewed-by: Guenter Roeck > --- > drivers/watchdog/watchdog_dev.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c > index 3bab324..ffd8f1a 100644 > --- a/drivers/watchdog/watchdog_dev.c > +++ b/drivers/watchdog/watchdog_dev.c > @@ -1096,6 +1096,8 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd) > watchdog_stop(wdd); > } > > + watchdog_hrtimer_pretimeout_stop(wdd); > + > mutex_lock(&wd_data->lock); > wd_data->wdd = NULL; > wdd->wd_data = NULL; > @@ -1103,7 +1105,6 @@ static void watchdog_cdev_unregister(struct watchdog_device *wdd) > > hrtimer_cancel(&wd_data->timer); > kthread_cancel_work_sync(&wd_data->work); > - watchdog_hrtimer_pretimeout_stop(wdd); > > put_device(&wd_data->dev); > } > -- > 2.7.4 >