Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp944775imm; Mon, 21 May 2018 17:49:16 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp7chVA5A5r0FAXhwVRki5WEeVPePQjQwdnatp4JdUr1AjvEKZCos+55eZQib1AoOa3WGPn X-Received: by 2002:a17:902:8d8c:: with SMTP id v12-v6mr22350919plo.366.1526950156632; Mon, 21 May 2018 17:49:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526950156; cv=none; d=google.com; s=arc-20160816; b=zKL5PTv55EdFcgfxWBPsB4sQLpMA0XzSi3QnjhKgr4PiKjQ09uM84veBj2rW/qGRK1 itrfhykOoKK0aDdIarBgry3n4xORp6hhG5+LiILmQVN1B5LHReWk8Ato9n7OPZM9AGgA pbSDn+UrRvyz/YBZoMnYUIgaTp77p5+aRJ2C+WvJgsZaDWsdQAwuG9JB2rg3f8y6ont/ C0QOuZWKmOYWrRDaUVfiqT45xIKiCHJyOA5aX72K08zk0nKvVBx2pqC93HQDPaBrIHO1 6COO9Wx0VtdezQZevTsHUtp7uokM4hJVDWYWnx9AxMpxfg0MsZfTsrt1bYNq8R34Z0CF Xc5A== 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:arc-authentication-results; bh=n3Z+2H3s6Rp+NzBg84Yar6eESzjfgWbpQMbbtnVrvd4=; b=gIbJdzK4SaFhc620Lo7wM6lH4SrkxYhFlWFOhlCnFzZF4XaCTrm8gKHiiXiUK3Sstd zBk67gep3ayAxy4Q3Bctk6abUo7vJ/hlog0dzHlh1dZN/n9HVxS4RK7R6sqTXdBOooMT zBRbaNsI1jY6cRCKqMYZ1bpqhPbOXuhTJ+TUKiqaAlke4UaES6UbePp/5DDWCUFVIXQx dVxh80S4LUkHvkPTtvdNE9ftUMvi+uWbeFeKKV2PQr5MpmL1SkL49nNVSGk4+t/1i258 vvzYi7wmUAUl/nNhdhU4gDSaMhKfwhWu5DFAl0rxP4x10+Y8vS4NQIsAUx5R3fl2MWyo ESoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=ZAble3sw; 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 f35-v6si14807120plh.193.2018.05.21.17.49.00; Mon, 21 May 2018 17:49:16 -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; dkim=pass header.i=@kudzu-us.20150623.gappssmtp.com header.s=20150623 header.b=ZAble3sw; 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 S1751657AbeEVAsv (ORCPT + 99 others); Mon, 21 May 2018 20:48:51 -0400 Received: from mail-yw0-f196.google.com ([209.85.161.196]:36991 "EHLO mail-yw0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751148AbeEVAsu (ORCPT ); Mon, 21 May 2018 20:48:50 -0400 Received: by mail-yw0-f196.google.com with SMTP id u83-v6so5046353ywc.4 for ; Mon, 21 May 2018 17:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kudzu-us.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=n3Z+2H3s6Rp+NzBg84Yar6eESzjfgWbpQMbbtnVrvd4=; b=ZAble3swA0PuiNRnIjxfJT/Rx88V4k/bIdNhxEMMfQYy8REQrdzCFTrEelE0I86bgJ 9M8h6Eow5oyfe3h7tfGu7fD2I6oEa3Qdhj0vZCsyo+bA9tYtCCLbTsGKxBeaj4LCxdYb 5D6IZp9QJXPEXQcsHVJY98rNtQZuM+DdneFVpL5C+iOqH/HZ4J90koTNUmyuWvXBRcXw AeyECze+JPxUfdrTs8CnPUvWFvDtRmsekq0ngE5osJ+bD8rZrSAk06nicDPI3LBpxs4/ yRFzIGdD2fyFrzyJOobhmG5EGqmHQ2+prI9LllPdm0JskPaAZVV82v99Q4O3WsKL54Me YUbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=n3Z+2H3s6Rp+NzBg84Yar6eESzjfgWbpQMbbtnVrvd4=; b=GfOkat0JCmN98s0Bf7HrRShHVlsFxYzGXKuh2a+ydrC7+Z+aoyCORoA2Y77cFTeZsS XAxUAtisnPyNZqbfQRpyL85acn03nomIMHvD9DHehlxpgN46I23szvem1rgiLGcKhbrj L33MngpLZetkTXknMY6hBn/NA2p8OFEASaz1Uy0swFsQhpL3X9m4SAW/QWJEqyGyFsHI 77V2X4gZGJdw9/2oIcV+rzmzooNB9gSt5zedmjIryvs87uvgSe0qd3h1W07HjuWMEuWi VBzAqlG0A4EUSbGaJ9bTsk6uXuXUY0st/dwVSjwwnNww3YAH8HypVrLbPuUrDCfNrNrh xsnw== X-Gm-Message-State: ALKqPwdvc+pp+Q9QPAs7uQG9AvvdbsykWDcp/QykGfpF23pUmTfyBTOl RGbFt6hQ0ooWiDX+UOTrIF2jeA== X-Received: by 2002:a81:10d6:: with SMTP id 205-v6mr5312904ywq.219.1526950129270; Mon, 21 May 2018 17:48:49 -0700 (PDT) Received: from kudzu.us (76-230-155-4.lightspeed.rlghnc.sbcglobal.net. [76.230.155.4]) by smtp.gmail.com with ESMTPSA id m203-v6sm6672832ywd.97.2018.05.21.17.48.48 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 21 May 2018 17:48:48 -0700 (PDT) Date: Mon, 21 May 2018 20:48:47 -0400 From: Jon Mason To: Arvind Yadav Cc: dave.jiang@intel.com, allenbh@gmail.com, linux-kernel@vger.kernel.org, linux-ntb@googlegroups.com Subject: Re: [PATCH] ntb_transport: use put_device() instead of kfree() Message-ID: <20180522004846.GC3255@kudzu.us> References: <6717325ea580df9a0294db6f83fd72a5db3daad9.1520591515.git.arvind.yadav.cs@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6717325ea580df9a0294db6f83fd72a5db3daad9.1520591515.git.arvind.yadav.cs@gmail.com> User-Agent: Mutt/1.9.2 (2017-12-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 09, 2018 at 04:03:24PM +0530, Arvind Yadav wrote: > Never directly free @dev after calling device_register(), even > if it returned an error! Always use put_device() to give up the > reference initialized. > > Signed-off-by: Arvind Yadav > --- > drivers/ntb/ntb_transport.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c > index 9878c48..8182a3a 100644 > --- a/drivers/ntb/ntb_transport.c > +++ b/drivers/ntb/ntb_transport.c > @@ -393,7 +393,7 @@ int ntb_transport_register_client_dev(char *device_name) > > rc = device_register(dev); > if (rc) { > - kfree(client_dev); > + put_device(dev); Now we are leaking client_dev, which is bigger than just dev. I think we are going to need both now. Thanks, Jon > goto err; > } > > -- > 1.9.1 >