From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29DC441754 for ; Mon, 2 Feb 2026 15:48:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770047299; cv=none; b=DVixTx1meJs/CJoZaREwROMbFGSQnT+sKIgGudXvmVCSM8NhAHQFlUInmIgq+aPu/bc+pSLuEuLdx3uIw2+6Pvpxjmdr1D2jzloBP24NiAOGUeIEds9i0c2/bhlP0c7tDfa2//nPzvZFg2HZDVl+7NCNWuREu2qtqsi9430Bo1I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770047299; c=relaxed/simple; bh=Afj17x91EXbt8Deh0bJOcz5m3G+WX3CU1VA7oRQAHDM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=A8NWSGLGOqUWSVJF3HuSfXvVzWySTQERnJN+jq1SAxeSAqEUojUU0PIgMusXgj0h0mrvn2RX9HWNv4TV7689pxo464Y5xJCsY0HUg1fWU9hy0FUUw5f0BIHvQuXL8PIXbNRshs1of7ye9EDHH1Ns5ZlRQqg73tdVhoq7b87uYN4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=NPtfqoEs; arc=none smtp.client-ip=209.85.160.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="NPtfqoEs" Received: by mail-qt1-f176.google.com with SMTP id d75a77b69052e-503347e8715so54347591cf.2 for ; Mon, 02 Feb 2026 07:48:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1770047297; x=1770652097; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=8lZnq3PJuhpE/1cANdV/zFSL+6ANg7Z+AIOF3gGB5qA=; b=NPtfqoEs4DDq+ywwZLt5DS2h2iLv0IqPwXJvq8tw/8ty2OLPZj9JA5Ai0NM8JX/z70 ekZINBlJ4YkqOrdKJ/ll4EECdSastaOfTPaeXiQWVsJvXELKnb8IfU8WnbN1l9YwP3pO 2aBL9pOLKKM9Hrk2nHL94O41NhK9mIsyD48k5StsWF+REQHb72FvVy+GzpqjMSTf/nW3 bNhLN3UqUWwXzgFamyqDh97SHsdEiLtmhlD/1vuNU5i2reM/YQZUgKI2irxT8BzQoYIH 0em/3ZyXxJCfw78H38Eb7B2EdkblU+60VZjbNfmiqoCymV+zkh+JR33+PcLFQb2lpOAC urFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770047297; x=1770652097; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8lZnq3PJuhpE/1cANdV/zFSL+6ANg7Z+AIOF3gGB5qA=; b=IUfMIoM/BAlbRJLZGKwJoDGiHiauNjH14HtQJfB4tlIZffVup+HsTMBVTPPWy1dJxG IjwWdMN6Qn104lcVm0hhcEkQjWwNIXLI1dPgU7QB/S1j/OwwLPaidBH10KBqmCU5h644 0OWGMxJFGIh0rXUHVMsj9r24P7wdMqIVNijF7dHvgwDTFdR9aYNyjs/K4kH9v4WQDXlt Pt3hmd1a3TVim+Zv3KEgFZ1p6NgFcHrMPhJFGPCrAoSO6hZY3q5sqZ5FPf9dYW6zPHKG UES7NanzSULdPCYufoC4DEWxwzlXCWiHflWyncDbvhmGn5sVRsLyz8iihHAzLkHvlQnh AisQ== X-Forwarded-Encrypted: i=1; AJvYcCUCjQZC/WVzQLm/I9siI+QS0sVKJxaa6JKMwx/ZMv9ppm5AUVM20N2lu7QyjrPVPVj2ZsvHnGWdL4wuMx0=@vger.kernel.org X-Gm-Message-State: AOJu0YxnzQSbY8qyyj3SVujJLVhzJ6QDh48rqbDh1EQXJmDrcbausrmt MWZYUqKuKehs+llgba/Bcdo4g85UiSGqpj+7/BhaNTGrvs9UDrOwq/v/nMdGiK20Y4A= X-Gm-Gg: AZuq6aLeiH4KZguEDwSJMVX6z8XNIg9yxXJGpPcGA1PQjodLSFSQlePMGAeZ0PAK4uW /ibLAqmUHW98sqfJSXC1JmZ2xtohSwpvzgCHhjfRUJkJkJpPHdhoXoa3QNTVUcC5npm+inzcR/T WlL8wGq95KBBFkmf9uZV17kTiCZMtn7u2YGoc9hMlrto025hR/tDQ0hHth4pNUdKrYBlKsDd2eH z+Cg9kSRDyZ6C6hu/Clp5Gio/YGGNJL/boT6wMHipA6VLdh3MgFiyEg5ck+3fZ+zk5JzaoG9kb0 wjldzuEh8EtBxQ4X1tSbrpPxLq6LWK0NkTeFmVg3yCx3tqTDk7ohXT875j/pmlDn5cmgbUknREX EIixNZd9/SOLrsotdSYeAP+39aYphSEJaGvqtDoJoObnud7hmKk9qs7S6bej6x63f0Y/uVQc4ow 1h+Ct22Ufi1bM5JTTS+n7yZdKNrWQvMzmG/QVFmuOB586tOTp3iibocpSN4ktBYx0Dbo1FZA== X-Received: by 2002:ac8:5950:0:b0:4f1:de1c:dfa8 with SMTP id d75a77b69052e-505d2190592mr188572491cf.19.1770047297079; Mon, 02 Feb 2026 07:48:17 -0800 (PST) Received: from gourry-fedora-PF4VCD3F (pool-96-255-20-138.washdc.ftas.verizon.net. [96.255.20.138]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-50337cbdc24sm112264261cf.32.2026.02.02.07.48.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Feb 2026 07:48:16 -0800 (PST) Date: Mon, 2 Feb 2026 10:48:14 -0500 From: Gregory Price To: Jonathan Cameron Cc: Li Ming , dave@stgolabs.net, dave.jiang@intel.com, alison.schofield@intel.com, vishal.l.verma@intel.com, ira.weiny@intel.com, dan.j.williams@intel.com, linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] cxl/core: Set cxlmd->endpoint to NULL by default Message-ID: References: <20260201093002.1281858-1-ming.li@zohomail.com> <20260201093002.1281858-2-ming.li@zohomail.com> <20260202144103.000016cb@huawei.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: <20260202144103.000016cb@huawei.com> On Mon, Feb 02, 2026 at 02:41:03PM +0000, Jonathan Cameron wrote: > On Sun, 1 Feb 2026 17:30:01 +0800 > Li Ming wrote: > > > CXL testing environment can trigger following trace > > > > Oops: general protection fault, probably for non-canonical address 0xdffffc0000000092: 0000 [#1] SMP KASAN NOPTI > > KASAN: null-ptr-deref in range [0x0000000000000490-0x0000000000000497] > > RIP: 0010:cxl_dpa_to_region+0x105/0x1f0 [cxl_core] > > Call Trace: > > > > cxl_event_trace_record+0xd1/0xa70 [cxl_core] > > __cxl_event_trace_record+0x12f/0x1e0 [cxl_core] > > cxl_mem_get_records_log+0x261/0x500 [cxl_core] > > cxl_mem_get_event_records+0x7c/0xc0 [cxl_core] > > cxl_mock_mem_probe+0xd38/0x1c60 [cxl_mock_mem] > > platform_probe+0x9d/0x130 > > really_probe+0x1c8/0x960 > > __driver_probe_device+0x187/0x3e0 > > driver_probe_device+0x45/0x120 > > __device_attach_driver+0x15d/0x280 > > > > commit 29317f8dc6ed ("cxl/mem: Introduce cxl_memdev_attach for CXL-dependent operation") > > initializes cxlmd->endpoint to ERR_PTR(-ENXIO) in cxl_memdev_alloc(). > > However, cxl_dpa_to_region() treats a non-NULL cxlmd->endpoint as a > > valid endpoint. > > > > Across the CXL core, endpoint availability is generally determined by > > checking whether it is NULL. Align with this convention by initializing > > cxlmd->endpoint to NULL by default. > > I had a look at whether it made sense to use use IS_ERR_OR_NULL() to check > for validity of the endpoint, but it would be somewhat fiddly and I think > you are correct that convention here seems to be NULL means not set. > We don't need the error code. One comment inline. > doing validity checks on pointers by checking for null is a pretty common convention kernel-wide, I would consider setting some structure's value to an ERR_PTR to be the aberration. So yeah, good catch Reviewed-by: Gregory Price ~Gregory