Received: by 2002:a05:6a10:eb17:0:0:0:0 with SMTP id hx23csp255877pxb; Wed, 8 Sep 2021 23:37:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfFGi9Ey9KhswqrZIxRk0o+1zXPBtLuZnE3NPzLPaspm3lqMfV09YbNcgRxBNx6L3M/8zp X-Received: by 2002:a17:906:e2d5:: with SMTP id gr21mr1674846ejb.401.1631169477188; Wed, 08 Sep 2021 23:37:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631169477; cv=none; d=google.com; s=arc-20160816; b=Op6yfy+tj0GTWSL4P2L1GUCkLoVtqP44nSJHNOz+xR4h2mVbTJUOANdAn9phbcgySM jAGdHkA9HRH+oaWbF6OysrH2mZLkvgzsjW2+/elWaiN9y2AxLNuO+I9L72S5e9MMmxmO dmRb1QaTfL/9w10ZB7+AF5FU/ZPgbamq+rOnR+K33BaAVV2gyH1KxwPKEkc78S7G1564 Hp3pUxzilqdJovG0pnYZOCkZmQbRe3ltJl1uNGME6CxddUB2MpoFhMDq5FLig6/dXPuS PpBvPRch7MI7JsSzfkW4ugJ/XagCox4caefyVQKVe+/NAxdySpWAZ7XUpsZ+Ds+cpakw sgZA== 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:dkim-signature; bh=JNGSXYieWlFux0GNdJ3h+HKrmdHEEWfgJkfR65r9Nyc=; b=AfV29DtuKaEM+p01XpaqdlWFoQCG2Q3oSco7dIUqalBv+OQPwzW99CFwGxo64Ziwgw H0RkKV7/cUwU6p9tGbR46ipYBBsPt+4oL2O4ugFTh1E3woorZbgb+RBZGs3oJLJplALm ZDDLxWxm5V0KYEff82fy5a/H7rxW2q8po1Hi8z7sHeUrNMEo0M//b7OTkDMcaNPCLz40 A/lipupR+74m9TmRPFqyaQkmOQ/l39THNPjeHq8zpdUJ9+9kDphN1vsvx2WTBhj3YLoN MeFYYG/KAcoukLZf0gKhIahYaf8V9JVc0XUkuLgiqRG5XyQ5Iv3lJmwY81Zyb8XyrPpp M7cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gJLnYWPa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c7si1041785ede.185.2021.09.08.23.37.34; Wed, 08 Sep 2021 23:37:57 -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=@linuxfoundation.org header.s=korg header.b=gJLnYWPa; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350807AbhIIFhj (ORCPT + 99 others); Thu, 9 Sep 2021 01:37:39 -0400 Received: from mail.kernel.org ([198.145.29.99]:59442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350802AbhIIFhh (ORCPT ); Thu, 9 Sep 2021 01:37:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 24E3E6113E; Thu, 9 Sep 2021 05:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1631165789; bh=++NHiiWo2jB3aeTKob1mBUql4iblQbvqYo4A2gIlx6c=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=gJLnYWPa4J7nWrVp909KOZwdd6uf9VSaKr5YMg3II62inKpgBr2nfcJ8LxLPUo+kr Vb1x54wQS+iwV7wqk62Ob8bmpnSy7D+3E4lmRnp1rk4b0eSJMDL1twakkNNXoK62Hm sQ+v1oR83GIqUwGa8XAEB0Wsro6OwlZoVA0Uy+ok= Date: Thu, 9 Sep 2021 07:36:05 +0200 From: Greg KH To: Zenghui Yu Cc: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, fujita.tomonori@lab.ntt.co.jp, axboe@kernel.dk, martin.petersen@oracle.com, hch@lst.de, wanghaibin.wang@huawei.com Subject: Re: [PATCH] scsi: bsg: Fix device unregistration Message-ID: References: <20210909034608.1435-1-yuzenghui@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210909034608.1435-1-yuzenghui@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Sep 09, 2021 at 11:46:08AM +0800, Zenghui Yu wrote: > We use device_initialize() to take refcount for the device but forget to > put_device() on device teardown, which ends up leaking private data of the > driver core, dev_name(), etc. This is reported by kmemleak at boot time if > we compile kernel with DEBUG_TEST_DRIVER_REMOVE. > > Note that adding the missing put_device() is _not_ sufficient to fix device > unregistration. As we don't provide the .release() method for device, which > turned out to be typically wrong and will be complained loudly by the > driver core. > > Fix both of them. > > Fixes: ead09dd3aed5 ("scsi: bsg: Simplify device registration") > Signed-off-by: Zenghui Yu > --- > block/bsg.c | 13 +++++++++++-- > 1 file changed, 11 insertions(+), 2 deletions(-) Reviewed-by: Greg Kroah-Hartman