Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp3316463pxb; Tue, 12 Jan 2021 11:26:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVJspyNu6KAgz9Ae6EHxWIH40zseIxClSbR7leAoYPqVy97RPMkNDgdt1IBF8zyG8mF223 X-Received: by 2002:a05:6402:2d1:: with SMTP id b17mr526061edx.95.1610479607407; Tue, 12 Jan 2021 11:26:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610479607; cv=none; d=google.com; s=arc-20160816; b=TGHWn+Xxeiap/akOjDu50/mT7x0q2tMhNXt8K2/xtuUuvCrOWSCkZB2HNFLFJ5Wghu U9FH7Iv4GRUucdnVqLEkf4UjuHAiWmnM7Sv7IpqqTJGJkkxxMi9jfhyFkdlsmSi9GC+0 s7yIS5h8M7b7yfMEoUSpdII8WxPtQZfLlQlbL4ACqJ0edIsof1+pfkTvYyMtzYiHXzl0 IKOUN2KxdMTsUExWbswpzVxy9U+/ezPvkyjkifjuMLoYL0AZJzyeN5AAepdCcj8XZkaT xTf65SLpFAKs5hgvfhr4wmsuYAEOxIOF2a97ywi7dKn4pzezitpy/yeDdU0K2AQUHqXN ZDRw== 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:ironport-sdr :ironport-sdr; bh=kMRYdi5qkCKBS4fvp686rwc0qpVJmmIBoADmuaovbao=; b=K6zuz8juJRwPNGfwaGbhflpuXKMb7Gy9OKptB6Mr6lgMBwW2zxqZaihdvErplvxzd/ kHXcZFRtvH5EyxAAKJQgePLHFkIN909Zdhw1DScIIycXTJuMgq2C4vvOjP3DH4uroQxL ZHCnwU3JJlhM2C1A9/cH8JQsvxBsklV07nEXixy1hUnNo/lOJWvYRGFR5Re+BfrGs8DS tSM5Bu6CTeaXy0J8/YQX0s3uaItzV2fwLbcA4QJQc6x1n9udnxJySv4lcNziYnJT/Ypp zOBgJtYA2XDkYcCR+zBEyj9VB9NXDg0laeLearRPPDOVvfTiJIuP/zqqNC8DQcDa0Rub rFsQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d21si1794478edy.92.2021.01.12.11.26.16; Tue, 12 Jan 2021 11:26:47 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436930AbhALTXs (ORCPT + 99 others); Tue, 12 Jan 2021 14:23:48 -0500 Received: from mga07.intel.com ([134.134.136.100]:24185 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436841AbhALTXm (ORCPT ); Tue, 12 Jan 2021 14:23:42 -0500 IronPort-SDR: YPT0wXNWfru/hvhwWhGJ3JLqK/xCZ6G6GCz32wV2T/sopgOWSrHH4pX1G5jn4vmi26fiNTDBZb 1ZUinCcYTyng== X-IronPort-AV: E=McAfee;i="6000,8403,9862"; a="242166399" X-IronPort-AV: E=Sophos;i="5.79,342,1602572400"; d="scan'208";a="242166399" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 11:23:01 -0800 IronPort-SDR: Di3yZCEWVNme9WZglDAaNAzcqXmxj2/R2QhYFms0cY8D57LS9jw+s5gEJwPey/5COoXz74C0n2 ut9QLpKDLVEQ== X-IronPort-AV: E=Sophos;i="5.79,342,1602572400"; d="scan'208";a="567618520" Received: from reyesjon-mobl.amr.corp.intel.com (HELO intel.com) ([10.252.129.71]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Jan 2021 11:23:01 -0800 Date: Tue, 12 Jan 2021 11:22:59 -0800 From: Ben Widawsky To: Jonathan Cameron Cc: linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-acpi@vger.kernel.org, Ira Weiny , Dan Williams , Vishal Verma , "Kelley, Sean V" , Rafael Wysocki , Bjorn Helgaas , Jon Masters , Chris Browy , Randy Dunlap , Christoph Hellwig , daniel.lll@alibaba-inc.com Subject: Re: [RFC PATCH v3 06/16] cxl/mem: Find device capabilities Message-ID: <20210112192259.2fnvlv2bmwkhd52s@intel.com> References: <20210111225121.820014-1-ben.widawsky@intel.com> <20210111225121.820014-7-ben.widawsky@intel.com> <20210112191744.00007d61@Huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210112191744.00007d61@Huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 21-01-12 19:17:44, Jonathan Cameron wrote: > On Mon, 11 Jan 2021 14:51:10 -0800 > Ben Widawsky wrote: > > > CXL devices contain an array of capabilities that describe the > > interactions software can have with the device or firmware running on > > the device. A CXL compliant device must implement the device status and > > the mailbox capability. A CXL compliant memory device must implement the > > memory device capability. > > > > Each of the capabilities can [will] provide an offset within the MMIO > > region for interacting with the CXL device. > > > > For more details see 8.2.8 of the CXL 2.0 specification. > > > > Link: Link: https://www.computeexpresslink.org/download-the-specification > > Signed-off-by: Ben Widawsky > > > ... > > > /** > > * cxl_mem_create() - Create a new &struct cxl_mem. > > * @pdev: The pci device associated with the new &struct cxl_mem. > > @@ -129,8 +214,20 @@ static int cxl_mem_probe(struct pci_dev *pdev, const struct pci_device_id *id) > > if (rc) > > return rc; > > > > + rc = cxl_mem_setup_regs(cxlm); > > + if (rc) > > + goto err; > > + > > + rc = cxl_mem_setup_mailbox(cxlm); > > + if (rc) > > + goto err; > > + > > pci_set_drvdata(pdev, cxlm); > > return 0; > > + > > +err: > > + kfree(cxlm); > > From previous patch that was created using devm_kzalloc in which case > this free just introduced a double free if you hit this error path. > Having go rid of that you can do direct returns instead of goto. Ah okay. Ignore my last email then. I admit I looked really hard to figure out how it ultimately gets freed and couldn't convince myself it does. If someone more familiar with devm says it just works, then I'll rip out all of remove (as it was in v2). Dan did fix this all up for me previously and I regretfully undid it. > > > > + return rc; > > } > > > > static void cxl_mem_remove(struct pci_dev *pdev) >