Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2152990pxa; Mon, 24 Aug 2020 06:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyQWuRd4sUyEKbHxUNRDQYLCKm5kde3QFUod6ovZ4r2xoCfGWCprqNXMSwuHfz8AeaSoqq X-Received: by 2002:aa7:da8e:: with SMTP id q14mr3383401eds.359.1598276659796; Mon, 24 Aug 2020 06:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598276659; cv=none; d=google.com; s=arc-20160816; b=LpxXQQ2eIlfjcXj43LEuWgySXR0VjUg5LyU2oHdyLHgbbF3HUy5xWeJYs29hH0PE6D uZnkLf5oaem1VJz4BtOOt37EtjRRs3v05LbbAlnikIip1It9vpgpLIbDsQz+hTNsuhrO 4/nbJtubaV+BNXKS3k8gbnqq2QlRnsOfVKPMTTyeBSFXCKR9Tbo0WJ9qhgZDkh/BD7nY LbQvMRfxVEcyn4CDkjbHcVAXpG432akrXgcvjuIbnbdKX1YjSRYtmKcxKLkJ02C7Gxzl d1jFK0fpESJldrUZ1SmZ9EDTe55R2Q2D7ilzrKkjiz9Xzt1Voh+7WaKGuyEAaysaVQ0w H20w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=KxnJ226rDEIRCYSAfgyQD9VSISjkVVFiQbho/xUa2SA=; b=WqSsX/hnhWSzR3n+fxTzp4pQ7TRzHM9OE+8ZKQFxHEEjooRKRyCxqUiPcqTSsu0Uo6 wmczjALG5G5UPZ+n0nLfkMPhfnOPNdD9ybkx0BMc5WCLDGXvI2qDjpeIrEdhMqAFbGcz ADOnMwpxhTMqpJkAVPdiBYudaqnu1u18tKTIfP/d94mzrXJ82CK2G1GJY/aG2kiE/9Ce MRqMdW2aKRBLVWmmNHFAZ8DnymLoTXtJsnn/XnMi1/FfZLD6b/YlkQ3oSYsVTVFrMceE 8PMx+/iDhVWHAEuKbgWxniBtkMpm/9F76onNTB7oufdrt4UHjpcfvD8AmHcz5vElgVUm tMDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=NMmyyMPg; 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 r6si6671675edb.217.2020.08.24.06.43.57; Mon, 24 Aug 2020 06:44:19 -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=fail header.i=@gmail.com header.s=20161025 header.b=NMmyyMPg; 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 S1727915AbgHXNkv (ORCPT + 99 others); Mon, 24 Aug 2020 09:40:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53930 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727116AbgHXNhb (ORCPT ); Mon, 24 Aug 2020 09:37:31 -0400 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7F429C061575; Mon, 24 Aug 2020 06:37:30 -0700 (PDT) Received: by mail-pl1-x644.google.com with SMTP id v16so4250442plo.1; Mon, 24 Aug 2020 06:37:30 -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:user-agent; bh=KxnJ226rDEIRCYSAfgyQD9VSISjkVVFiQbho/xUa2SA=; b=NMmyyMPgB/lrfnnRRTyR4UPqUE/BEx0i2SqGdFdnIR5BqKp+uXn58ArQ9p+GBWGXBG ga3kv+F6nJNaZ4aa1iIfYJvoXVylqsq6BXkOflL5RHQpXN8oetMgfb9Pag33aZoZ4Ufc bs5aluqrYiYOOA6008C7gl4/JZvEf6w6EMbtQ25UvXVSLL6Q1Fo67IUW00eLkPlf20ca Hm9fXSpvbYkqzxnZjw8MeRBSxxAZEI/+V7vp+uGooTrn4JiQpnn0bKGBrAUY0Cy7+iTB fz5LxtHabotoJNfBiZukJbuJiKmqfyBrv2j1wToMfeYUBXoJsJFpvHFNn+zoUNmssTEL 1/kw== 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:user-agent; bh=KxnJ226rDEIRCYSAfgyQD9VSISjkVVFiQbho/xUa2SA=; b=dNa7c1R1Kz1L6Ganppk9Ty/OutlzWAPmiZoaZpFkMZJsyfQJGQ4LV71L1B7KjIRPRN ucmEBkpfd+vHIWaYKDVZ99Z2Dd7Pi2YZ8KID+cOtH2ypWdF5ljKrj0CR/GjpFcKwdYNY nZ/mrGS0DIJBlSuKUy4lOSeY+0eVxaov95cj5v731DaewylM0bwBYxwEgv89BORehP1V 7NHpRM1HBuQSF1D+T2E4TdfAEz1JZfIXfuKHWUmyJG1PDcM3bKt3AlVnzTQzWstFWzxs 6sNvnYdnhRJx3iRBWpJRYsC5XoUlLQvY7/n66LLfiQgED3TcHnK+sEzfyAqDAPd/5NL5 2aPg== X-Gm-Message-State: AOAM530vsJRENw6oTx6WTFGbolltOp9tT0oP2lTDTF4IbOq49D+WRYCi BiaO9KdMDf5qU1+woraK/xs= X-Received: by 2002:a17:902:d90e:: with SMTP id c14mr3804333plz.76.1598276250112; Mon, 24 Aug 2020 06:37:30 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y7sm10518969pjm.3.2020.08.24.06.37.28 (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 24 Aug 2020 06:37:29 -0700 (PDT) Date: Mon, 24 Aug 2020 06:37:28 -0700 From: Guenter Roeck To: Dinghao Liu Cc: kjlu@umn.edu, Wim Van Sebroeck , Krzysztof Sobota , Alexander Sverdlin , linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] watchdog: Use put_device on error Message-ID: <20200824133728.GC192024@roeck-us.net> References: <20200824031230.31050-1-dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200824031230.31050-1-dinghao.liu@zju.edu.cn> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 24, 2020 at 11:12:30AM +0800, Dinghao Liu wrote: > 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 Reviewed-by: Guenter Roeck > --- > > 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 >