Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp12908pxb; Tue, 12 Jan 2021 18:28:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJyej9aIvv9jjWDvR0qNDt7pm9QvobL1zD64awUQASwqHMU/sUHvhucdceKKG4FA7apxPs27 X-Received: by 2002:a17:906:e093:: with SMTP id gh19mr1249217ejb.510.1610504902095; Tue, 12 Jan 2021 18:28:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610504902; cv=none; d=google.com; s=arc-20160816; b=SLQfyiVjkNYaCSo7pV6lv4khWF8a08ZKonzpyrI2xJiPZfYCQC2+YX+nY9KB1W8p+j TwcXs4HeFfEXc0wh1fZUQd3Cxg9/rhOjpyXLx7nQOr7kk/321LRBpbRLhdoEYP8AzobY NtFD+n7hqerjy8Vp58/DjEkTkgecHLuEDvE1iT8WYvuBB/vlkzxCStUJJatpNu/6ug4e 62VsZvtsgzmojf2TPFEEyp6SS7GGcpMdwWl2OoYiPceD+S6bqFiroO1P3cfl7qFF2hKd d379+xogRvcGR8lL+VEer/E0JDk0MP4Ps9nEVpXTjggK5RoeydCqaKre6wuV/oX44smp BN0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=19nmgTESXeci/IpTSUrcJ/jKx4tLiXM0iUOpMqx48ig=; b=ChJGAS3FWW0R+yV+j8Tk0RpXE7c1q+2STqNOWLSuDqNFfzuTb63a02krE53TuRqHAX vpTbM0JkXfY7nBtrIO5LaNiNSm85OY+6RVsPsBjkNCTWHU3YT6gBKC+br7Az8DexeLC7 n3JMK0Ro+Udpb7cq7YtEkkejCRLe1B4TpS3CL4Ds4EKAcMeXYqrQYg9+bJLFGXan8aZd Lua8dTDxXPDOOdMrlrWE/unaRL2qN10+zb2rjmwYH9QhFeCZUBqOCb3y8x1s63KfFHA5 3O3XKcjGN9zicznSjoG6PWdJ26BLL7BrVd6B0IhjRKa7NI5yMt4sr4oA2xpJtOjFPpHE 1fqQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z7si299441edx.473.2021.01.12.18.27.58; Tue, 12 Jan 2021 18:28:22 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2436514AbhALTTG convert rfc822-to-8bit (ORCPT + 99 others); Tue, 12 Jan 2021 14:19:06 -0500 Received: from frasgout.his.huawei.com ([185.176.79.56]:2327 "EHLO frasgout.his.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2406399AbhALTTG (ORCPT ); Tue, 12 Jan 2021 14:19:06 -0500 Received: from fraeml742-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4DFgHX1G61z67TR3; Wed, 13 Jan 2021 03:14:32 +0800 (CST) Received: from lhreml710-chm.china.huawei.com (10.201.108.61) by fraeml742-chm.china.huawei.com (10.206.15.223) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 12 Jan 2021 20:18:24 +0100 Received: from localhost (10.47.65.219) by lhreml710-chm.china.huawei.com (10.201.108.61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 12 Jan 2021 19:18:23 +0000 Date: Tue, 12 Jan 2021 19:17:44 +0000 From: Jonathan Cameron To: Ben Widawsky CC: , , , "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" , Subject: Re: [RFC PATCH v3 06/16] cxl/mem: Find device capabilities Message-ID: <20210112191744.00007d61@Huawei.com> In-Reply-To: <20210111225121.820014-7-ben.widawsky@intel.com> References: <20210111225121.820014-1-ben.widawsky@intel.com> <20210111225121.820014-7-ben.widawsky@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 3.17.4 (GTK+ 2.24.32; i686-w64-mingw32) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 8BIT X-Originating-IP: [10.47.65.219] X-ClientProxiedBy: lhreml752-chm.china.huawei.com (10.201.108.202) To lhreml710-chm.china.huawei.com (10.201.108.61) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > + return rc; > } > > static void cxl_mem_remove(struct pci_dev *pdev)