Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp2955909iog; Mon, 27 Jun 2022 06:27:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tKCOz0DTiAM7lHhH39+v+zBnE31fnTfZivARUkIDuj5AJXr7NBNBYE3EunhQX9feDNuV7H X-Received: by 2002:a17:902:eb86:b0:16a:f36d:741a with SMTP id q6-20020a170902eb8600b0016af36d741amr7580432plg.149.1656336429783; Mon, 27 Jun 2022 06:27:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656336429; cv=none; d=google.com; s=arc-20160816; b=uPcw3qEtQsCd95XzFboqCIpy98H8BqBgqTpmJE3gxZmAz/IFTKx0zqyPWON93oI0jJ HgzLeAnJTFT5zBrQL6ek7r9KhVLA7kLPvm5SY59/PsPfqagmJGwEqMe2dS0jMTD3fjuY HGRt2YGwdPLc9hdgpmfC9fbfLOBnA80gtHVOGwr3wFU46hpXl1MxX059DCkeXig5wNEt oNZb2suprqJXYGHYjiCIKvuCBhnN4OMQN3/1rmf6R9n12hIV6PXEmZahQ3o/fhmUcv2P kKIo2YnMHJRHm8O40erY3xG7UZqvVVV3AfwxnLlr6XeIla79KP1Q5BR+MWoXYOaO1v9m iDKg== 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=vXCVSbsaqE0s2uLRNMbIXHyD3RIS0sJFSzNyTFfURLI=; b=aj+P4LBoR2IID6nL3y5E1OMrGrL+FAzojZyolCZBZsiA0Zzgs9maz0MF40gPqEEiag qt/zyd1RTp+b5dD3ISV5ujH5i914Mn9sCc0chDTNSO+NkHgxy0QGNbHXHdYJpkRkRPNr o8bYs2Dyj093M+AmG7w9H58y78VjGj3GE5eSopag71MyBBo2wIrqBzQm9oX1QFPfDTyb UNH33tNmmU4zZCtb2uiKhm/nMav1djbnGGkNyxsNSx5SwQdPSnuNhdEMuYAUA7pIc+3B MeQE0M8KJ52HcNrpsmZ+E5ZwEVB//cAx415/FFXGo7Fbf7XP++xZCVC4AMgooNWhthz2 tqlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tK2eCWyS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 204-20020a6302d5000000b0040d9515987asi12638464pgc.62.2022.06.27.06.26.49; Mon, 27 Jun 2022 06:27:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tK2eCWyS; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S234658AbiF0NWB (ORCPT + 99 others); Mon, 27 Jun 2022 09:22:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234136AbiF0NWA (ORCPT ); Mon, 27 Jun 2022 09:22:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3680226F7; Mon, 27 Jun 2022 06:22:00 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C6D1661275; Mon, 27 Jun 2022 13:21:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C841EC3411D; Mon, 27 Jun 2022 13:21:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1656336119; bh=E1q1+oBwOrnDHyb2Ekxn6ULxemjx+uZKthjCDjiYI38=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=tK2eCWySAeRn2bVVsb40r2/51hQYbCOiWnET4CRa3SAB1XqLrGCcaBonuxa59EwsN iQA/IV2qXZKBNb63s2aVIYXKMbnDnP6wDfnUcxu3muWhENpg+LLfr+X3rY7zSrve/8 biw0OMZBwYYjK2nyCOaTImriODMYpAp7xm/fXv8w= Date: Mon, 27 Jun 2022 15:21:56 +0200 From: Greg Kroah-Hartman To: Zhangfei Gao Cc: Arnd Bergmann , Herbert Xu , jean-philippe , Wangzhou , Jonathan Cameron , acc@openeuler.org, linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux.dev, Yang Shen Subject: Re: [PATCH v2 1/2] uacce: Handle parent driver module removal Message-ID: References: <20220624142122.30528-1-zhangfei.gao@linaro.org> <20220624142122.30528-2-zhangfei.gao@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220624142122.30528-2-zhangfei.gao@linaro.org> X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Fri, Jun 24, 2022 at 10:21:21PM +0800, Zhangfei Gao wrote: > Change cdev owner to parent driver owner, which blocks rmmod parent > driver module once fd is opened. > > Signed-off-by: Yang Shen > Signed-off-by: Zhangfei Gao > --- > drivers/misc/uacce/uacce.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/misc/uacce/uacce.c b/drivers/misc/uacce/uacce.c > index 281c54003edc..f82f2dd30e76 100644 > --- a/drivers/misc/uacce/uacce.c > +++ b/drivers/misc/uacce/uacce.c > @@ -484,7 +484,7 @@ int uacce_register(struct uacce_device *uacce) > return -ENOMEM; > > uacce->cdev->ops = &uacce_fops; > - uacce->cdev->owner = THIS_MODULE; > + uacce->cdev->owner = uacce->parent->driver->owner; What if parent is not set? What if parent does not have a driver set to it yet? Why would a device's parent module control the lifespan of this child device's cdev? This feels wrong and like a layering violation here. If a parent's module is unloaded, then invalidate the cdev for the device when you tear it down before the module is unloaded. Yes, the interaction between the driver model and a cdev is messy, and always tricky (see the recent ksummit discussion about this again, and last year's discussion), but that does not mean you should add laying violations like this to the codebase. Please fix this properly. thanks, greg k-h