From patchwork Sun Aug 11 00:18:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13759653 Received: from pv50p00im-ztdg10011201.me.com (pv50p00im-ztdg10011201.me.com [17.58.6.39]) (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 998358836 for ; Sun, 11 Aug 2024 00:18:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335538; cv=none; b=sjlnlrOZylc+cZ2JZCbvkuw0R3kcDK21xuX+ML+Q5/6Srcm1muiOPm1HUcgYg6CFBDpspLPq2km2AIuv2gDvVm7xsomTnRi939DohDq6v9oRWeWwIEOMwgIsTnlDeRm7EPm0t9eczC+R1Wf1T1Mi4g3a+k1rb2TBJXQn9rsJQOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335538; c=relaxed/simple; bh=re8ejkZvR8FVYAGOwc9z54pZxgx5nHBnmfXZfJuIUdc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=f3h9+EV60n1KaWVBaQm0yZKbfVM5oXsooOFLmsj0rD1xniCOQNKhK6G547S47D5c0QzTvYiNWpbgX73l0nwvtCFmCf4BX2WRr+MzkcIjHl4o6ZCvotjiMr6uSIHGzhGsKnXwBIS4F2EYCfKnraZOTMtO8+qDABqluAO7t4wAPJs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=nrCig10r; arc=none smtp.client-ip=17.58.6.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="nrCig10r" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723335537; bh=3UDcyf0LKLJLPbT+GMinmsXhG9jmFzc5b/d5UWg4m2Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=nrCig10rluhFXgdriAaxFLUOAf2AXOVXbz3G8nKxrxGQAJqnngo9/3BryP20A5C6C isOKYIH1GiMwCzGrDeYQlLRSJmDBgPcq3WvOonS0K1naKtQKQVYmABXJB4f9+gnTuD vDOraZ4PpWbWqt2mBqQUBPomPPX397sJefdu2XzCKgDjvG1gwuRLcQDgVMbr2TDWk0 7IyUEyUVGjyH9iL7NswUZORYp2PxW5HTmdOR2fBYDb+yAIDfuTdI54WygYtiIArVIS 7DXUDDRK2X+Ke1ohegY4WY1XimMgJ/HNoLEtP8vX9gChD/KOLhaaYdWb6G6kDCr7rD LJFImnCKSN2KA== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id E97626801A0; Sun, 11 Aug 2024 00:18:49 +0000 (UTC) From: Zijun Hu Date: Sun, 11 Aug 2024 08:18:07 +0800 Subject: [PATCH 1/5] driver core: Add simple parameter checks for APIs device_(for_each|find)_child() Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240811-const_dfc_prepare-v1-1-d67cc416b3d3@quicinc.com> References: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> In-Reply-To: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: W1Q-lleN0G8WMlC2eRQQv8yYNEw2v1JX X-Proofpoint-GUID: W1Q-lleN0G8WMlC2eRQQv8yYNEw2v1JX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-10_19,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=888 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408110001 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Add simple parameter checks for APIs device_(for_each|find)_child() and device_for_each_child_reverse(). Signed-off-by: Zijun Hu --- drivers/base/core.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/core.c b/drivers/base/core.c index 1688e76cb64b..b1dd8c5590dc 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4004,7 +4004,7 @@ int device_for_each_child(struct device *parent, void *data, struct device *child; int error = 0; - if (!parent->p) + if (!parent || !parent->p) return 0; klist_iter_init(&parent->p->klist_children, &i); @@ -4034,7 +4034,7 @@ int device_for_each_child_reverse(struct device *parent, void *data, struct device *child; int error = 0; - if (!parent->p) + if (!parent || !parent->p) return 0; klist_iter_init(&parent->p->klist_children, &i); @@ -4068,7 +4068,7 @@ struct device *device_find_child(struct device *parent, void *data, struct klist_iter i; struct device *child; - if (!parent) + if (!parent || !parent->p) return NULL; klist_iter_init(&parent->p->klist_children, &i); From patchwork Sun Aug 11 00:18:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13759654 Received: from pv50p00im-ztdg10011201.me.com (pv50p00im-ztdg10011201.me.com [17.58.6.39]) (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 C6B9A3D6A for ; Sun, 11 Aug 2024 00:19:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335547; cv=none; b=sPHPh6HERIjn0YqovYHlz8/bxT2gvOjBj6fQqa17uHDFzbGvAHV6QLrg+nU2+LroXiCPMSs1FT9MgIDrSyuK/k1sRYB+ae4Hl88OGxi5r2mhpI4aI/XajjT8WNAH2uXcvbqKT2YltkhaIWRHZSr1Zv1W4U1nT8O/nJuZG+Ccgzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335547; c=relaxed/simple; bh=/jVTmq9o3o0MWDoG2EpUvZebIjiBmxqTBVe+zvhWThY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mQVzkkf7NfjtFe1cmXcjwfesiMN90Ody0WViXZnctHVgsz3RwxErDGDoH06q0Dd3lDIyTGFrVyUwL1jPQ6hyVx5yq7cSm6COzdnZilGYh5sfQtZ7gph2QG3ZmpP8xbuRHpugFV3v8tpEyDfPGzpYZk61MFIoIbrmEGvZdpJor8U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=gMSjexnO; arc=none smtp.client-ip=17.58.6.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="gMSjexnO" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723335545; bh=8ACfFczv50hhSd0C+OEzjxc/3oNgPFKi42Hm5mF33zY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=gMSjexnOEdW4l+6MTPntwI6HyUiWXsZq2JBHkxheRrZTySVN4qY3znsgN7+T444zm pu9ZIn6ZP2t1M+F0Ns6kQMPg2aWBq8vIEEPloerypHRCJb7C70cYoXJWfTGjjXn70p oboHjm/5/F7NRLUO+OWTcXPfzdBYp83ErkIiswVAa7MsN1uy3HMiEZdTuPilz1V1rJ pBSjBfjmjLe1yQflmmvcZI5bqJJKKdPDI7SYkwD2BHn5DrgHfMI2nRmIySjTAhB/ab BIl9zJalPvN0e3nwlJx5EKhyFaPlFOjazPwl7ZagiP3zOwWMJ6VAI4wPFaaJXJbzEp hfCn7tZEFMfCg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id F391F680179; Sun, 11 Aug 2024 00:18:57 +0000 (UTC) From: Zijun Hu Date: Sun, 11 Aug 2024 08:18:08 +0800 Subject: [PATCH 2/5] driver core: Introduce an API constify_device_find_child_helper() Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240811-const_dfc_prepare-v1-2-d67cc416b3d3@quicinc.com> References: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> In-Reply-To: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: YUExqy0AGD5seRjb7nYKURCcmx4cVajI X-Proofpoint-GUID: YUExqy0AGD5seRjb7nYKURCcmx4cVajI X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-10_19,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408110001 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu Introduce constify_device_find_child_helper() to replace existing device_find_child()'s usages whose match functions will modify caller's match data. Signed-off-by: Zijun Hu --- drivers/base/core.c | 35 +++++++++++++++++++++++++++++++++++ include/linux/device.h | 7 +++++++ 2 files changed, 42 insertions(+) diff --git a/drivers/base/core.c b/drivers/base/core.c index b1dd8c5590dc..3f3ebdb5aa0b 100644 --- a/drivers/base/core.c +++ b/drivers/base/core.c @@ -4128,6 +4128,41 @@ struct device *device_find_any_child(struct device *parent) } EXPORT_SYMBOL_GPL(device_find_any_child); +struct fn_data_struct { + int (*match)(struct device *dev, void *data); + void *data; + struct device *target_device; +}; + +static int constify_device_match_fn(struct device *dev, void *data) +{ + struct fn_data_struct *fn_data = data; + int res; + + res = fn_data->match(dev, fn_data->data); + if (res && get_device(dev)) { + fn_data->target_device = dev; + return res; + } + + return 0; +} + +/* + * My mission is to clean up existing match functions which will modify + * caller's match data for device_find_child(), so i do not introduce + * myself here to prevent that i am used for any other purpose. + */ +struct device *constify_device_find_child_helper(struct device *parent, void *data, + int (*match)(struct device *dev, void *data)) +{ + struct fn_data_struct fn_data = {match, data, NULL}; + + device_for_each_child(parent, &fn_data, constify_device_match_fn); + return fn_data.target_device; +} +EXPORT_SYMBOL_GPL(constify_device_find_child_helper); + int __init devices_init(void) { devices_kset = kset_create_and_add("devices", &device_uevent_ops, NULL); diff --git a/include/linux/device.h b/include/linux/device.h index 34eb20f5966f..b2423fca3d45 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1078,6 +1078,13 @@ struct device *device_find_child(struct device *dev, void *data, struct device *device_find_child_by_name(struct device *parent, const char *name); struct device *device_find_any_child(struct device *parent); +/* + * My mission is to clean up existing match functions which will modify + * caller's match data for device_find_child(), so please DO NOT use me + * for any other purpose. + */ +struct device *constify_device_find_child_helper(struct device *parent, void *data, + int (*match)(struct device *dev, void *data)); int device_rename(struct device *dev, const char *new_name); int device_move(struct device *dev, struct device *new_parent, From patchwork Sun Aug 11 00:18:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13759655 Received: from pv50p00im-ztdg10011201.me.com (pv50p00im-ztdg10011201.me.com [17.58.6.39]) (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 24EBB12E5B for ; Sun, 11 Aug 2024 00:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335555; cv=none; b=ZlRwz/3tTl4E0o0M9UPIhNuT1qKi/8AjhQ8wRbCi9ooAeD6omsIVVSPo56Dp38sNPtzJfGaLHlKFm9A2nIAkkq0VWK7yxIf37x2ByzmGMQ3RLAraSywAfh4ylL5dN3Lj+HmmTRpFu5GgCzYJES8YNbPQd8XxH3cqffYeN9hVdOc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335555; c=relaxed/simple; bh=oA3Js3ltLTQOz5GHCGYDw8dr7WcHDELikHbf0Vk8kXk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=hxEbfYuImxVkb0tWFglXJDeA2QWF7A0Ymh9ca9QJBSEp4jlqLhasEGh1amI/mrCgneCPyqgkgwGzSDUWeKWqTlXdhEkqtXg8JEu+Jdecyo0OX2SMo/JxHx/d6mzkDhI3DfOmihhY9la+fZ9oRMtslCbCrYlhJVxSxhzVna2GjkQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=igoOmbtz; arc=none smtp.client-ip=17.58.6.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="igoOmbtz" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723335553; bh=8iLjtO/2UXxucyitQe69VJHXy2XEjJ9kRumhC5PiJ+Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=igoOmbtzbxQqSGdzywSmKnHik61FBl6kOxCh02CuA1XxWoehwFm6hNLEXYtZvz8XZ ghRA8nGYpojJ7zA1x8vHMoAUSasvDBDXm+cm/tdHITL/bNcCDOIPlXlEEuXIigW80I vm1kxlKIscRwetjdKa1jhRUTbr933dL88JekzFTks8HK1P2/LD6c4wkzAzP55wLIwV Bt/eqD21xhF12XcCO4ajChsZm358EYdGsvxsdgiTs3jXpf/xkFtv40HiaSYaNWCHvt DRL7ej9GYMuzwMBFwEcMSuLby3uRc9tAZ3V2pa1skYY/ithSQosa6dT/asKTiPQufO gBeTsgWWIGDIQ== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id 566576801C9; Sun, 11 Aug 2024 00:19:05 +0000 (UTC) From: Zijun Hu Date: Sun, 11 Aug 2024 08:18:09 +0800 Subject: [PATCH 3/5] cxl/region: Prevent device_find_child() from modifying caller's match data Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240811-const_dfc_prepare-v1-3-d67cc416b3d3@quicinc.com> References: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> In-Reply-To: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: xS6x43nsXihcVsLJkLkDbU8lkUP042gU X-Proofpoint-GUID: xS6x43nsXihcVsLJkLkDbU8lkUP042gU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-10_19,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408110001 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu It does not make sense for match_free_decoder() as device_find_child()'s match function to modify caller's match data, fixed by using constify_device_find_child_helper() instead of device_find_child(). Signed-off-by: Zijun Hu --- drivers/cxl/core/region.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c index 21ad5f242875..266231d69dff 100644 --- a/drivers/cxl/core/region.c +++ b/drivers/cxl/core/region.c @@ -849,7 +849,8 @@ cxl_region_find_decoder(struct cxl_port *port, dev = device_find_child(&port->dev, &cxlr->params, match_auto_decoder); else - dev = device_find_child(&port->dev, &id, match_free_decoder); + dev = constify_device_find_child_helper(&port->dev, &id, + match_free_decoder); if (!dev) return NULL; /* From patchwork Sun Aug 11 00:18:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13759656 Received: from pv50p00im-ztdg10011201.me.com (pv50p00im-ztdg10011201.me.com [17.58.6.39]) (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 6CD4817BA4 for ; Sun, 11 Aug 2024 00:19:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335563; cv=none; b=toEjTrkRB7jyfF+S+Tat9hCczICSxi1/ao6wYictUVAYOVOgl8f6EEglMDxxakKJGYqyU8W0Ff1llao2DJR53k8zsn4cQmyezc096g9PDyZVQcqrpr7zx9FQzXHCBbdoJ++iOROl3E3/Tob55fS5T0UiHSQmEO0Na4vGV5YV8HI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335563; c=relaxed/simple; bh=hYNvkRkIcW2oTdaAe1DL5t3Si3lhBCDEpXFBGD4nl4Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=HlyPK//nvS1rQbut7gMFTuTOvNugfrMMOH2f1f1X2t45z0NOvA6EouopkVPMLC2ees7fNUg9DbyXnk3zz/CJEIR+UklZeGwD8C4AMOdEDWkDGNmJjE6oM3NU5ijuNXubmI3dj4++FFtSZL+PVIJq/P6P4GQvuGJP6BUyl9Ohsak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=OvTX1o3P; arc=none smtp.client-ip=17.58.6.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="OvTX1o3P" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723335561; bh=gWCJf+B9a9UHAx2h7q4TRGp4fm2U07ewbdekbtDQiZk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=OvTX1o3Pure4JxwNEgLEi3OgFw02Ni3RcUc586kB9lCnzsSClPhETXHOQqsKvP6xT hqdgHv/Rii1jUQCCj+oUYoS356PGwrHrGSW43ATPxXyHuw3q3K1mHANnbi1LMi/ycp oAIreEnxP+gwAAPl4BXDRPYX/L0y+pfm86GRrympj2cArz1edH27OHZnuqsJ4kU+mw xP+AecqEA6T9+5rmgbxJP/CY3YbTD64rdPAW+7LHSazM5zhRk1NYTAATNpnin9qqwU JwPtX1kiC8A8lI/cFpf6x2e3CZpj3D+4DeJIbOLNkFFHHyQrb4NzvC42JCg2yvzIYB Q3ySM4zzYkE6g== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id 6BF736801B0; Sun, 11 Aug 2024 00:19:14 +0000 (UTC) From: Zijun Hu Date: Sun, 11 Aug 2024 08:18:10 +0800 Subject: [PATCH 4/5] firewire: core: Prevent device_find_child() from modifying caller's match data Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240811-const_dfc_prepare-v1-4-d67cc416b3d3@quicinc.com> References: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> In-Reply-To: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: iI2CTLznNMjORgoPu_DAX5efHY63bgD5 X-Proofpoint-GUID: iI2CTLznNMjORgoPu_DAX5efHY63bgD5 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-10_19,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408110001 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu It does not make sense for lookup_existing_device() as match function of device_find_child() to modify caller's match data, fixed by using constify_device_find_child_helper() instead of device_find_child(). Signed-off-by: Zijun Hu --- drivers/firewire/core-device.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firewire/core-device.c b/drivers/firewire/core-device.c index 00e9a13e6c45..04b150bc876d 100644 --- a/drivers/firewire/core-device.c +++ b/drivers/firewire/core-device.c @@ -1087,8 +1087,9 @@ static void fw_device_init(struct work_struct *work) return; } - revived_dev = device_find_child(card->device, - device, lookup_existing_device); + revived_dev = constify_device_find_child_helper(card->device, + device, + lookup_existing_device); if (revived_dev) { put_device(revived_dev); fw_device_release(&device->device); From patchwork Sun Aug 11 00:18:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zijun Hu X-Patchwork-Id: 13759657 Received: from pv50p00im-ztdg10011201.me.com (pv50p00im-ztdg10011201.me.com [17.58.6.39]) (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 1B99DDDC5 for ; Sun, 11 Aug 2024 00:19:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=17.58.6.39 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335571; cv=none; b=C9kal8RYlhxLHod7AWJwy7nVJWq4N2LT/rnEeE2XIu+8hoiL8oK7fzecU1wggVsAotqE0GT6V+qptWX5yc1CXJpIPYbhpAyfQOnGqeLgXc/XsJZcJcmKKm0OLfJDjoDiWMZ8tHpAL3YBkvgeFiHulJMssPFQV3y2nl9/v80rlZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723335571; c=relaxed/simple; bh=KvOpYbmYWjV+rXzyCv7qf0TDxg/EynZxXUCOxIezkv0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RvTSQ7T4++IBjNuKPtLK6aASdoBF54uxyPMuGnPAIEoAYb2/rhR61i7iXrlgWrmoXbMo5RbP6PZBWmt03jG9/naJc1Cd69eJywHqf6lHh8WbKEVvSzCa02NOBek+FEXTfiyD7gJp+Uq+z93ryn1Kkh4I4LJFWZvNiCPV0GOaM1g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com; spf=pass smtp.mailfrom=icloud.com; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b=qmYKKRLx; arc=none smtp.client-ip=17.58.6.39 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=icloud.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=icloud.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=icloud.com header.i=@icloud.com header.b="qmYKKRLx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=icloud.com; s=1a1hai; t=1723335569; bh=g0ifbuA5vAN4F2zvFBRG6+qhsDphBeYH944qW7z03P8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:To; b=qmYKKRLx9Y82CbRQ5af60iWurvgbjfFFy1jHlL2/cDHM7exhNOdzRoXacrnKaVrq0 1GPSIZcgi4HderXO8iiaTSTmoF3eCUvwTgnIDuc1mWACn7xf+0noHRNEtBE+aa3QTp yeoDztR5HIGyQUBmWZw4PppRM8o4GEldznvFNauP30lg7uBysSzlTOQzNPm2InqyMu +egkE3WcX1oc5j012t/UVATl3PmYF1JG+Z8iWaZSYOqUdpQ8vCJ09BH8jQ9itxi5lk 1MzKTrnaMON87PrCpyXJsBE39O4pG0pxsQLi6/sEZmjm24fHWDzoKQkZB+7cTc4E6C srV2ji0zC/vvg== Received: from [192.168.1.26] (pv50p00im-dlb-asmtp-mailmevip.me.com [17.56.9.10]) by pv50p00im-ztdg10011201.me.com (Postfix) with ESMTPSA id 701106800FC; Sun, 11 Aug 2024 00:19:22 +0000 (UTC) From: Zijun Hu Date: Sun, 11 Aug 2024 08:18:11 +0800 Subject: [PATCH 5/5] net: qcom/emac: Prevent device_find_child() from modifying caller's match data Precedence: bulk X-Mailing-List: linux-cxl@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240811-const_dfc_prepare-v1-5-d67cc416b3d3@quicinc.com> References: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> In-Reply-To: <20240811-const_dfc_prepare-v1-0-d67cc416b3d3@quicinc.com> To: Greg Kroah-Hartman , "Rafael J. Wysocki" , Davidlohr Bueso , Jonathan Cameron , Dave Jiang , Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Takashi Sakamoto , Timur Tabi , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Zijun Hu , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux1394-devel@lists.sourceforge.net, netdev@vger.kernel.org, Zijun Hu X-Mailer: b4 0.14.1 X-Proofpoint-ORIG-GUID: 6F8FPtT7sCunyxHLCfRp5cxUElMTOGvd X-Proofpoint-GUID: 6F8FPtT7sCunyxHLCfRp5cxUElMTOGvd X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-08-10_19,2024-08-07_01,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 phishscore=0 mlxlogscore=999 clxscore=1015 malwarescore=0 bulkscore=0 adultscore=0 mlxscore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2408110001 X-Apple-Remote-Links: v=1;h=KCk=;charset=UTF-8 From: Zijun Hu It does not make sense for emac_sgmii_acpi_match() as device_find_child()'s match function to modify caller's match data, fixed by using constify_device_find_child_helper() instead of device_find_child(). Signed-off-by: Zijun Hu --- drivers/net/ethernet/qualcomm/emac/emac-sgmii.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c index e4bc18009d08..e53065756a1d 100644 --- a/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c +++ b/drivers/net/ethernet/qualcomm/emac/emac-sgmii.c @@ -358,8 +358,9 @@ int emac_sgmii_config(struct platform_device *pdev, struct emac_adapter *adpt) if (has_acpi_companion(&pdev->dev)) { struct device *dev; - dev = device_find_child(&pdev->dev, &phy->sgmii_ops, - emac_sgmii_acpi_match); + dev = constify_device_find_child_helper(&pdev->dev, + &phy->sgmii_ops, + emac_sgmii_acpi_match); if (!dev) { dev_warn(&pdev->dev, "cannot find internal phy node\n");