Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1868184pxa; Sun, 23 Aug 2020 20:19:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyxqEraZ8b+hZZQbuQeLj6+2LWY32Ywkd+JR3IsFeGFu2fzFPEM65DZk1ZDf21w97PUSoBf X-Received: by 2002:a17:906:b248:: with SMTP id ce8mr3580025ejb.85.1598239152944; Sun, 23 Aug 2020 20:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598239152; cv=none; d=google.com; s=arc-20160816; b=F8fcS8+Uq+cMeBvJW0jd+eeZyFA6TPt9UUVvolX2clwW5BwlK6nbYHUy0DJMcOa2kW Mqe92GBye+eqkL6wOfwixR1f21/0mPD8g6rhi3Um726YCYtfMdXl33H9DSP5Rug6V/2A /YRLOvGD1dh5y0oyikC/fURvi2+3K1Gq7gvZLl53sEv/axlU2hRG2VCp+6MlttU92FSe oUkh2dUpfTZokdzL7e88ajVP6m+JIJnPsuf0OvWCcUCZbR26lhnIqNpd5FMqv8XVPfpN S3MRX3zzmiM408lLsOt2PsIcM956uWLa/slnMOQgV6PaFtAymKe34CmRqcEOCVGWs0UW t1kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=peVe4AoOdYG2ytKIrQxsWvMqBW0BfDlWi/sB86ZbZ+E=; b=YdD59gK7Dy4PWuKrKQg87/sq7pDQQF7Zgo1lmN2hw1MaBwWte42c1B2BHMaTrUGHBN vGceZQEto77TA7yHinpjTfAmZtIVpmwSEAqARNFboDXAZAtLi8OdgBHw5K449XpCgHHD p/JEE4heu4NFva/K8AA4t0yF4fjuSMFTx2DGhtgfBTVqsOPLmepTJlRoqB2HnIz0rox8 9ksHdWpPLM8tpiVfKqqflpCxD168A+kjlKMMEFr5jXaFLh+L2F1r0H0PemnlA1TRkh3C x17J25UmJtsR+bC/HNBhG0eRqJPIAigufxy269ZMjuAWuNQfXQYGmlsvprm6yis8r4Ih pF3w== ARC-Authentication-Results: i=1; mx.google.com; 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 w13si6241231edq.220.2020.08.23.20.18.50; Sun, 23 Aug 2020 20:19:12 -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; 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 S1727841AbgHXDMv (ORCPT + 99 others); Sun, 23 Aug 2020 23:12:51 -0400 Received: from mail.zju.edu.cn ([61.164.42.155]:24088 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726635AbgHXDMv (ORCPT ); Sun, 23 Aug 2020 23:12:51 -0400 Received: from localhost.localdomain (unknown [210.32.144.184]) by mail-app3 (Coremail) with SMTP id cC_KCgC30d0fMENfP8QbAw--.23170S4; Mon, 24 Aug 2020 11:12:34 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Wim Van Sebroeck , Guenter Roeck , Krzysztof Sobota , Alexander Sverdlin , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] [v2] watchdog: Use put_device on error Date: Mon, 24 Aug 2020 11:12:30 +0800 Message-Id: <20200824031230.31050-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cC_KCgC30d0fMENfP8QbAw--.23170S4 X-Coremail-Antispam: 1UD129KBjvdXoWrZFyxWFW8Cw47Xw1UCFWDCFg_yoWfuwc_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el.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We should use put_device() instead of freeing device directly after device_initialize(). Fixes: cb36e29bb0e4b ("watchdog: initialize device before misc_register") Signed-off-by: Dinghao Liu --- Changelog: v2: - Use put_device() instead of just removing kfree. Move the memleak part to a separate patch. --- drivers/watchdog/watchdog_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 6798addabd5a..b0fa7f31b1b6 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -1021,7 +1021,7 @@ static int watchdog_cdev_register(struct watchdog_device *wdd) pr_err("%s: a legacy watchdog module is probably present.\n", wdd->info->identity); old_wd_data = NULL; - kfree(wd_data); + put_device(&wd_data->dev); return err; } } -- 2.17.1