Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp472213imm; Wed, 11 Jul 2018 05:53:26 -0700 (PDT) X-Google-Smtp-Source: AAOMgpftj0NRe/C8SNFBnwbGD0BtWkb5YKq8l8dP3JqXJJ/U8Cl736TFO1JfnwtIyQE1Ql+Wnmiz X-Received: by 2002:a65:448a:: with SMTP id l10-v6mr26744665pgq.382.1531313606547; Wed, 11 Jul 2018 05:53:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531313606; cv=none; d=google.com; s=arc-20160816; b=gZRWzCXgbDmAriu+A0OdPzH7czepBa/oOfjfFODhR9EVJZB09kHNd0qZJ+/oLIsJ5u pSrDrWtu2s+ZofE7BCUVFNtU990tuNtQD0XaVAL8LouVBUPn4ebV89a4ZtOdggxb0t2T mWmKHxqXBgPo3AYucGbTuljtxMp7QV6H16Ua902OpNYc1TOvZHJ+2TiHNAhF+/FBuKaw sNNFZttw6MxnSgZ6L/9qq+ZglVOSRTjW7wut6muo7KpHYtsXU6RbNHBumePek5qhoRX+ QSvT+duwS6/Q/CmpZMWqWCPcXl+uZ322fUIggNJKQ18xuCIk5nec3FRFG44L3GZg910E G4DQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :message-id:date:subject:cc:reply-to:to:from:dkim-signature :arc-authentication-results; bh=wIUGwOS0ZnxO7jJbtzXaKonWuhMsIv/Y+8zlBr20xqE=; b=mpUphe17SFtFs4Vu25GKHf/M9ODovRKMLksVYAuE+KyUEkiuIK2psWvZghYSHorFTN 656+U42+rYucnlvnkgTItyCSWWzz1+E0URTfpCGHlIHwMc+eNQlJpNZoD8yZCGDwJ9uc zVN9/znAQ3V94ZiSDKZ8oNK7w8xh6q9zZohw+BIfrC50emIHRrBVbK7SZvs5t3njrdig 0bozsZLfe212C39fT1/yYCominfhwJ6uaq5iHUtUWF6pB0LvTUUb7UUlVQfTg7l9Uh6I +APNBr7L/YCocYs4wjhRR3RUAC2lAW9NBggfwdkHs5ZbNEvI+O2Et2Wii16inMJvOr7n 9HKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cern.onmicrosoft.com header.s=selector1-cern-ch header.b=cBF2ei2O; 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 31-v6si18787459plz.217.2018.07.11.05.53.10; Wed, 11 Jul 2018 05:53:26 -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=@cern.onmicrosoft.com header.s=selector1-cern-ch header.b=cBF2ei2O; 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 S2387598AbeGKMmx (ORCPT + 99 others); Wed, 11 Jul 2018 08:42:53 -0400 Received: from mail-ve1eur01on0086.outbound.protection.outlook.com ([104.47.1.86]:62082 "EHLO EUR01-VE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1732385AbeGKMmw (ORCPT ); Wed, 11 Jul 2018 08:42:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cern.onmicrosoft.com; s=selector1-cern-ch; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wIUGwOS0ZnxO7jJbtzXaKonWuhMsIv/Y+8zlBr20xqE=; b=cBF2ei2OblebMfQ3ujBZM9NvsqOSBRZyTHHRHEjfs4+7jqZGC5KNFV4O1wZAnDqzt3r0Fz6PSUeGzt8N1Il7RBA9XFCp0Z8Ma7LO+gllo3qV3NeUC/okgFhrvcyFDJ3uBZoeEHN7BPrc93DvsKGYOSi/y+s/8C3C5v3jdCBxRgk= Received: from HE1PR0601CA0010.eurprd06.prod.outlook.com (2a01:111:e400:c513::20) by HE1PR0601MB2474.eurprd06.prod.outlook.com (2603:10a6:3:95::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.906.20; Wed, 11 Jul 2018 12:38:40 +0000 Received: from AM5EUR02FT049.eop-EUR02.prod.protection.outlook.com (2a01:111:f400:7e1e::202) by HE1PR0601CA0010.outlook.office365.com (2a01:111:e400:c513::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.952.18 via Frontend Transport; Wed, 11 Jul 2018 12:38:40 +0000 Authentication-Results: spf=pass (sender IP is 188.184.36.48) smtp.mailfrom=cern.ch; kernel.org; dkim=none (message not signed) header.d=none;kernel.org; dmarc=bestguesspass action=none header.from=cern.ch; Received-SPF: Pass (protection.outlook.com: domain of cern.ch designates 188.184.36.48 as permitted sender) receiver=protection.outlook.com; client-ip=188.184.36.48; helo=cernmxgwlb4.cern.ch; Received: from cernmxgwlb4.cern.ch (188.184.36.48) by AM5EUR02FT049.mail.protection.outlook.com (10.152.9.233) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P256) id 15.20.930.16 via Frontend Transport; Wed, 11 Jul 2018 12:38:39 +0000 Received: from cernfe05.cern.ch (188.184.36.45) by cernmxgwlb4.cern.ch (188.184.36.48) with Microsoft SMTP Server (TLS) id 14.3.399.0; Wed, 11 Jul 2018 14:38:30 +0200 Received: from pcbe13614.localnet (2001:1458:202:121::100:40) by smtp.cern.ch (2001:1458:201:66::100:14) with Microsoft SMTP Server (TLS) id 14.3.399.0; Wed, 11 Jul 2018 14:38:27 +0200 From: Federico Vaga To: Alan Tull Reply-To: CC: , linux-kernel Subject: fpga: fpga_mgr_free usage Date: Wed, 11 Jul 2018 14:38:29 +0200 Message-ID: <5553262.evi6GU8epL@pcbe13614> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Originating-IP: [2001:1458:202:121::100:40] X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:188.184.36.48;IPV:NLI;CTRY:CH;EFV:NLI;SFV:NSPM;SFS:(10009020)(39860400002)(396003)(136003)(376002)(346002)(2980300002)(438002)(199004)(189003)(5660300001)(786003)(336012)(23726003)(26005)(44832011)(7736002)(305945005)(230700001)(486006)(50466002)(426003)(33716001)(246002)(3450700001)(47776003)(74482002)(86362001)(6116002)(4326008)(7636002)(14444005)(33896004)(9576002)(316002)(126002)(43066004)(16526019)(478600001)(966005)(97756001)(6916009)(46406003)(106466001)(8676002)(9686003)(8936002)(54906003)(476003)(356003)(106002)(2906002)(186003)(6306002)(39026011);DIR:OUT;SFP:1101;SCL:1;SRVR:HE1PR0601MB2474;H:cernmxgwlb4.cern.ch;FPR:;SPF:Pass;LANG:en;PTR:cernmx12.cern.ch;A:1;MX:1; X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 36815d06-3959-4857-937a-08d5e72b3aab X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(5600053)(711020)(4608076)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(2017052603328)(7153060)(7193020);SRVR:HE1PR0601MB2474; X-MS-TrafficTypeDiagnostic: HE1PR0601MB2474: X-Microsoft-Exchange-Diagnostics: 1;HE1PR0601MB2474;20:BafznFwy6qelHjXtG7GntWk3Wlr/I8c+owedHS+AKoG5vHhzVPOuxN/qVw0cDgJjGkH4v/uEe1HzcA/TOptIiJK4S1nKsamI8jDLoMtl2fppYef1C70EkmSJVorwo4nJfCO7qf4Um3g9tSZrRHKi/jm3Jz4iXmOgQg2f1nThqfZF1ONk1fmssex/vo9/R6Wff2JXLc2KJhUNWnemlGdOKx9Ob5xh5qrOhPg7HSHkgtHb+QGiwKiFR8hKmqs/1swCTV49Nxu7nAt8hLWY+CyZZkNfm79hTRArBsI3UF4VLS9SR7q7z10Bbr4/o4/fb3BFF90WWy/z1u8BCGzDQQX0M0X0cN+dCux15361r252oF4iG9J4pibfAOrtypPDiaCBefWgd6hO4Hd019SI7dGdgS+J9fUJ6dn/cAqCX0mgVixQOv0Q31maPgusMdxXXV63s4qhM7DeSIoHMSna4npiaLwYbESUh/+fB3SPlJnfATfmtIOAo1vFvL5J9zAxXl0c;4:XWGG37FS6gYojpEwjfrEEZa8LKuXVreXxxNYvpXb2TfbijE2xaFydmBfcEaBFV6q0X0nHJBmbEtoYiizJWWtU5OnU61sjhl8VHELO66S2Nfp3WgwwgW+pkjnP0gPHF3/1k8DFCNmiirB4ai57jcaclkvM7LAt+/KoS4XRIpob9Vx9D8QbRpTGucQ7y8al640J0tBy28PG/CwinfgPiXrA3Jd8C/GH9S3um411LpMqBiC+QCtJdQeLzNfEYjcFP7AFH14p/pZbd0/oaxGYwTosQ== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(93006095)(93004095)(3002001)(10201501046)(3231311)(944501410)(52105095)(149027)(150027)(6041310)(20161123558120)(20161123562045)(20161123564045)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:HE1PR0601MB2474;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0601MB2474; X-Forefront-PRVS: 0730093765 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1;HE1PR0601MB2474;23:Cab7dqrzzQt4z27hkzz0i4o64miEW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G5BWeGWt8LbNoba9T3X+/oZpIH2ZGMTgUb82EpvLH7nd5pI+BAwRttIForlm9Um0AQP4A5V8px3ebpuTHIJ1EPu8H/JvmY7aE4eH+rc6WNp2zOCcZpi15IKKMCQJyw1gr29V9qQlPCUt9VMJT1932bKU1twjQ9+k9hCUl3q/Yb5Z/iBNOdsOmug==;5:M72L0ArNpg+pccOV9Y1+PWZl4gGBL98hdHuuyXWy0yy9InosMRUzYA00iWUbiRDaEb10CH/QI6o2tCkQwstsf93spUNgb8gVSV342CbjmecQjlAgHx9aoUvrktzj5fZo7JU02B4TSZi4bNU9I4Zt3UwDyP2fGaEZblntgWidgDU=;24:1KJj4Lepw8AshhqiW4LPWsebLRKqBUjl8k/q4paFLfYEZIv5hQDfRSs1HJ9cnQ09p8MhIuEKi4g6oG6GrzKo+Kex+/wu7lc9o/A7lW7+GnA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0601MB2474;7:WCTShL7mlTfOb6ZRjB/Tpy6M0yYDirf9dj9SaABcPFzmG9x9wHLzKgGt9zUJd0xAFR220jd7Dqsgj2wFcLA39dJwj+aWEaGMDh7wBosUbCWRwBn+wR1hVbI8ZZBR+RB9Do4L8pzSpAjAVraSANTSKQxAxy8lkXbb1dtO3QmzDNh/9NqQbIn02nFSkFt/llw6tu7uJ706LerA0y+2fNmNs4jMCPlfr4x5wjbRvwKtYL2YUpLZBvfVqwwoSN5fZ/lB X-OriginatorOrg: cern.ch X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Jul 2018 12:38:39.4382 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 36815d06-3959-4857-937a-08d5e72b3aab X-MS-Exchange-CrossTenant-Id: c80d3499-4a40-4a8c-986e-abce017d6b19 X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=c80d3499-4a40-4a8c-986e-abce017d6b19;Ip=[188.184.36.48];Helo=[cernmxgwlb4.cern.ch] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0601MB2474 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Alan, I have another point that I would like to discuss. It is about the usage of 'fpga_mgr_free()' which does not look like consistent. This function, according to the current implementation, can be used by an FPGA manager user and it is used by the FPGA manager itself on device release. This means that the user can only use this function if fpga_mgr_register() fails (to clean up), otherwise the user must NOT use this function, otherwise we most likely get an oops (NULL or invalid pointer). The example here is correct, this is what we should do: https://www.kernel.org/doc/html/latest/driver-api/fpga/fpga-mgr.html But I suggest to document it better or prevent this type of mistakes from happening. Following a couple of proposals ------ 1. Document it better. This is easy, in the fpga_mgr_free() kernel-doc comment we explain that the use of this function must be limited to clean up the memory on a registration failure. If an FPGA manager has been successfully registered then it will be freed by the framework itself. But still, this does not prevent an oops from happening. ------ 2. Remove the fpga_mgr_free() from fpga_mgr_dev_release() and ask the user to free the manager when necessary. This makes the usage consistent: the user creates and destroy its own objects. This is also consistent with our other discussion where we said, among the other things, that the module that uses the FPGA manager can the owner of the fpga_manager data structure. ------ 3. Not sure how, but perhaps we can be able to understand if we can safely continue to run fpga_mgr_free() or we should stop. ------