Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp638476lqt; Mon, 18 Mar 2024 21:09:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXjrKFJrgxq+PyI90V6Pbu1DkV/2oipY0k/EK2CliGVOp0w6S2VX0w9GMl6OtN2Y+mi1ZadF6KIcGKsba0SoxqeHXijzCUAG4c6mhku1A== X-Google-Smtp-Source: AGHT+IGMkPrugV+6WnsxQpRL6BDs7zrqx0gIyyl1U57H9A736joqVcayr2UwEELrIf2cCruciIZI X-Received: by 2002:a17:90a:77c8:b0:29c:735:a758 with SMTP id e8-20020a17090a77c800b0029c0735a758mr2323606pjs.19.1710821342128; Mon, 18 Mar 2024 21:09:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710821342; cv=pass; d=google.com; s=arc-20160816; b=e9Jl0cfFeKMMe8ECVBxv06mnUvP+llIzedIBMciJyZtMXZ32RJ8QKbu6d0Y+3+k9yP asP2LsTaZH1eGXkzWru6MLZM2w5peXc9mkrGN54a49ZZzkumshQ18cB1epm9+E4h7Tg1 5ir6TnpXk+KvwAmhs1tYNDrqQA9nYY9sviBSD7GUcOA4OGxIm2MIoheuyM2AptNvGIcS 67XSaz3ZtwUzqmmF6XCseHUUAHLuWsipmligSHFO6Kmfk2Wn+u5Hpm1PrPc8cMM4auyV oqAqDWqPXuA4h1e6EsKwy3bkXo1xi2qHkMr0FycIjtKxwg2DY3o4MXS3ewFx5kYgTf29 IauQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=nP6s7kGiXUmaAOhhQaY8MoCjg1vV6QV/OQ6Cy+3JTJ8=; fh=FhDb9nm4o9ojrcM3mLNvO1+eSmY4sKGz432NSasjwpY=; b=VwdQZ8N1j6Nn8pV6/usXfZTjQzDbgI/SdLD3x4yaVA+2/W2NjEX0vym5SRO/46Idar 7vq6Tqkyoo82DSlq5So6WRbM0EcNhhAFIIZ3jX+OdUDQY50svziJy/7w2v20vji47j/d 9m7vgOp+NdfxzMz0cmB7wv7GoCuzi9ieqvvB9EjiQp05h8CZGlA+xU6qcBeeEItq6QdF LfAM19Cav7d9BlspeoCaVarY5bmawpzXyV0lmZaeTkuBxqSyf4rzPsIQ+7Q/63ppBQX3 mggbgMv2TDtbZgRJfPPimwnW5nJ7pnsvDQd83dMG8Q+S4aHnhphHV1bxv1Es03qNbrqO s/dA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lgNWNKmY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id z33-20020a17090a6d2400b0029bc9ac7164si9385955pjj.90.2024.03.18.21.09.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 21:09:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=lgNWNKmY; arc=pass (i=1 dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-106984-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106984-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id CA04D282D3C for ; Tue, 19 Mar 2024 04:09:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B2127C090; Tue, 19 Mar 2024 04:08:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="lgNWNKmY" Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B0AF07BAFE; Tue, 19 Mar 2024 04:08:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710821330; cv=none; b=lmjY+FU+Gog3m7iFGFCWN1B0c3r647oDYaf11cQp8Hp/krBQD2eGMCvPFNNik+bOjR8Z2SQOoBkXpQ/ca3nVJvalYL1TAG9NVFgqKcEh2E22FcDTJKCOl1QiILgELjR78jR4aHOpXvnmKLRKkIfLXeWN4zONokBUOJn4/KPnQnI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710821330; c=relaxed/simple; bh=FXJUWaXDFajafiGH9N/Lk6GWxmCJ3Z1AE7/I+I2yb60=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=NvIjxc8rXTiMpXI7B+Y9NyA2w+X6oqaNYYn4uUShV1esia5gUKd8Ckzb9PoTeGovKy+P2YPyXcWawTKBCbejPdgC0SVwFAnowa5IBhnD/8mKXq7EJqj6sh9St7zutfM33ARA9AA5l3Br9KmOU0hyjHn+O8rdmeSavSLct6UuO0s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=lgNWNKmY; arc=none smtp.client-ip=192.198.163.7 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1710821329; x=1742357329; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=FXJUWaXDFajafiGH9N/Lk6GWxmCJ3Z1AE7/I+I2yb60=; b=lgNWNKmYoIp55fPt+7/MkjjnnWqiSzq9u4msetrwfnjplwOamyhDZ3LW kFt7u4C6G3UEfxjZZPN5dw5ltHy/hpfKoCJ0Pur25Ehx1ZX38wB8DSnhn C3V5rneWXF5Jo1hL/WefwWdyVEPXrwZ3k6C6skMqN0F7+slKCls3jr9rk F0wwGe2aeWRFLmOeKsOPuCw5Z7NhwMlNXLsm8kbaHEWNXX10GfpJgbi1o OmkqwDcLNEFxvHeIcTs27+StkSABIUTNW+ldvdbMmRE8jJq1ppw2g6hTx lyAFhdons97eAVSYpgfDRDgemzyZNesHxoUT/nnk3Nbcpdx9hPZP7tc0C g==; X-IronPort-AV: E=McAfee;i="6600,9927,11017"; a="31100354" X-IronPort-AV: E=Sophos;i="6.07,135,1708416000"; d="scan'208";a="31100354" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Mar 2024 21:08:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.07,135,1708416000"; d="scan'208";a="13566078" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.165]) by fmviesa010.fm.intel.com with ESMTP; 18 Mar 2024 21:08:45 -0700 Date: Tue, 19 Mar 2024 12:04:13 +0800 From: Xu Yilun To: Marco Pagani Cc: Moritz Fischer , Wu Hao , Xu Yilun , Tom Rix , Jonathan Corbet , Greg Kroah-Hartman , Alan Tull , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-fpga@vger.kernel.org Subject: Re: [PATCH v6] fpga: manager: add owner module and take its refcount Message-ID: References: <20240305192926.84886-1-marpagan@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240305192926.84886-1-marpagan@redhat.com> On Tue, Mar 05, 2024 at 08:29:26PM +0100, Marco Pagani wrote: > The current implementation of the fpga manager assumes that the low-level > module registers a driver for the parent device and uses its owner pointer > to take the module's refcount. This approach is problematic since it can > lead to a null pointer dereference while attempting to get the manager if > the parent device does not have a driver. > > To address this problem, add a module owner pointer to the fpga_manager > struct and use it to take the module's refcount. Modify the functions for > registering the manager to take an additional owner module parameter and > rename them to avoid conflicts. Use the old function names for helper > macros that automatically set the module that registers the manager as the > owner. This ensures compatibility with existing low-level control modules > and reduces the chances of registering a manager without setting the owner. > > Also, update the documentation to keep it consistent with the new interface > for registering an fpga manager. > > Other changes: opportunistically move put_device() from __fpga_mgr_get() to > fpga_mgr_get() and of_fpga_mgr_get() to improve code clarity since the > manager device is taken in these functions. > > Fixes: 654ba4cc0f3e ("fpga manager: ensure lifetime with of_fpga_mgr_get") > Suggested-by: Greg Kroah-Hartman > Suggested-by: Xu Yilun > Signed-off-by: Marco Pagani Acked-by: Xu Yilun Will apply to v6.9-rc1