From nobody Mon Feb 9 07:11:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 8CAF015B547; Tue, 2 Jul 2024 14:53:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932001; cv=none; b=eydRVeVJcz3ra2HmKVFCneHyNL9mKuvefT2pjrBd3f1jnf5dne650x1evqnfhKlZKhvqzDTHnRlVowzK//xt+cZzPDbtjfLp13AbOR1iDZmmHZU+flYkbArreXIGOVyF2WKzE68dxAXdjM7hZfyrsSR1P4sGpuwtAuayQL3TQN4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932001; c=relaxed/simple; bh=zcCtez33jxnSqrsoNJ2ilJIZSKvzvgLXSNJz43K6oog=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=un6w0aIvUP8kSqyYR0z40UXP1Xa+JWdwI1zH9ePRtgxsiNNj7/dsIg//1HWKgoCfGHWOWV3TqWr6/Ux/G02R3rL6KDuIb16EoxoAoVqTwoHLYgL1S1WUl9pA6/HeWqstul57LJ16RWUYLanhWWAt6lHrAAHeDiXp8q+HcHyvK14= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=PRbmnxhV; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="PRbmnxhV" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 462BkNNo023818; Tue, 2 Jul 2024 14:53:13 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=dKP+ucAMMUbfxe8W55+nUzpQ OhfSVnudwj8XPSpegIM=; b=PRbmnxhVWm5heIIvRUNM8ZNh6NXabXWj6jw0Vosp HCNLorGmCFinDPJLbqbkvEPMXFElDc5ER4XPzYzF6obkvCcPNi0mSgQFV/nX6OKA YV5rfvu0IEB7fIAM+82FFW1tIVKz328EFiVXwl2Py0fUC/2LMFoH6yNgmk8f7hV/ VpS1R6pDg3jjfIy2pvRdSoaA5V/8slesLxzeJrOA8uHtUCNMJO6YHTm6A6RFYAX/ ld59m2kEQ0BVfa2+Za4l0BnZgKWMKNpg4xoyy2bdTJIZUNNsoZncz2/P3b6veevN N9sdTHejE9usj9b3TdNyeXEzgo0E+qee0fNpiHgwnIQNKQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40297rrqj6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jul 2024 14:53:12 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 462ErCCQ014703 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jul 2024 14:53:12 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 2 Jul 2024 07:53:09 -0700 From: Zijun Hu To: CC: , , , , , , , Zijun Hu Subject: [PATCH v1 1/5] devres: Fix devm_krealloc() wasting memory Date: Tue, 2 Jul 2024 22:51:50 +0800 Message-ID: <1719931914-19035-2-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: xzUWOC4h4MF3GOcZirwnSTiPlnc3L6bF X-Proofpoint-GUID: xzUWOC4h4MF3GOcZirwnSTiPlnc3L6bF X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-02_10,2024-07-02_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=799 lowpriorityscore=0 clxscore=1015 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407020110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Driver API devm_krealloc() calls alloc_dr() with wrong argument @total_new_size, so causes more memory to be allocated than required fix this memory waste by using @new_size as the argument for alloc_dr(). Fixes: f82485722e5d ("devres: provide devm_krealloc()") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- Previous discussion link: https://lore.kernel.org/all/1718531655-29761-1-git-send-email-quic_zijuhu@q= uicinc.com/ Changes since the original one: - Correct tile and commit message - Add inline comments and stable tag drivers/base/devres.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 3df0025d12aa..ff2247eec43c 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -896,9 +896,12 @@ void *devm_krealloc(struct device *dev, void *ptr, siz= e_t new_size, gfp_t gfp) /* * Otherwise: allocate new, larger chunk. We need to allocate before * taking the lock as most probably the caller uses GFP_KERNEL. + * alloc_dr() will call check_dr_size() to reserve extra memory + * for struct devres automatically, so size @new_size user request + * is delivered to it directly as devm_kmalloc() does. */ new_dr =3D alloc_dr(devm_kmalloc_release, - total_new_size, gfp, dev_to_node(dev)); + new_size, gfp, dev_to_node(dev)); if (!new_dr) return NULL; =20 --=20 2.34.1 From nobody Mon Feb 9 07:11:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 5C3CB1B581C; Tue, 2 Jul 2024 14:53:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932010; cv=none; b=rrItmpM+8SSzpizwZO06S0bXbXi3JV/XZMKvWDLCwnSsAe2KJ43c4b2KFIOJQ9ZDUC5+BXjIbqQKVMhxmnccuOJqakjMW89nQnsBDEviCpN7I98O1jdl15JTC57cgKhRpeqLtd7hqHhIhv3e4t62jh/aEcBPoS3xArha5xjH9+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932010; c=relaxed/simple; bh=b/1dUwC6RKrgPfMKrd9Jt4y4dSvrS1/lDZs7JH/wD+U=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hn4hhALFDdpNaTxZmNTEwOFvZidUMogZzc8F++rpJKZTsWRZY/lXUww/4qNfs0Yyzp7OmBm0ctbx02q+hx22PlYdvhzieUjXqDkxW7YEzevq+Ahh4/DddxRKEsAGzmI/Ez7gGOykBVH6bdozmB1MP4H8lvA9BwNTYlgVmvXoHOg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=UBBFXPki; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="UBBFXPki" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 462EVBev028802; Tue, 2 Jul 2024 14:53:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=p8scXDmGAH0jtAF/6OgbD0Eo v/EYHKGkXAx07XvDz9E=; b=UBBFXPkigAxj+ZdgjL1fDmwJfe6Nxgb0iiQLlxKz C0n6xG2C3ekBBaa9wSbUqbR0vP1SJsLjj9sFQP8wXQtPAo9q9PrkwykoRy25ymb/ SonWDOWxw1OLp06DHkH/h46PP+S5/nTeRV+axir7UdMFUQrPktZXcXQNdJ6BGJST LmRPyMc75QyzcnOLdykHl+L3w2svSl9xdcaXSVPwPP0lY/1JZjeLepL0wKtuL5O9 aHAYsNljqIXcyhM8mqe/E6R3HHsQC2rKeRGZ008o0xCW4NQ3VKnTBwilXpFg63AO v5w5sptggcgHQv1o41dE5yvM213ZeGyLEoTe/L5dl0ptkQ== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 404kctg521-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jul 2024 14:53:18 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 462ErHrA014775 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jul 2024 14:53:17 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 2 Jul 2024 07:53:15 -0700 From: Zijun Hu To: CC: , , , , , , , Zijun Hu Subject: [PATCH v1 2/5] devres: Fix memory leakage caused by driver API devm_free_percpu() Date: Tue, 2 Jul 2024 22:51:51 +0800 Message-ID: <1719931914-19035-3-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: 7tqcNHbKDwUGOLeGRAzPKXpwVtUtEtWs X-Proofpoint-ORIG-GUID: 7tqcNHbKDwUGOLeGRAzPKXpwVtUtEtWs X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-02_10,2024-07-02_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 adultscore=0 bulkscore=0 mlxlogscore=503 priorityscore=1501 impostorscore=0 suspectscore=0 mlxscore=0 lowpriorityscore=0 clxscore=1015 malwarescore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407020110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" It will cause memory leakage when use driver API devm_free_percpu() to free memory allocated by devm_alloc_percpu(), fixed by using devres_release() instead of devres_destroy() within devm_free_percpu(). Fixes: ff86aae3b411 ("devres: add devm_alloc_percpu()") Cc: stable@vger.kernel.org Signed-off-by: Zijun Hu --- Previous discussion link: https://lore.kernel.org/lkml/1718804281-1796-1-git-send-email-quic_zijuhu@q= uicinc.com/ drivers/base/devres.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index ff2247eec43c..8d709dbd4e0c 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -1225,7 +1225,11 @@ EXPORT_SYMBOL_GPL(__devm_alloc_percpu); */ void devm_free_percpu(struct device *dev, void __percpu *pdata) { - WARN_ON(devres_destroy(dev, devm_percpu_release, devm_percpu_match, + /* + * Use devres_release() to prevent memory leakage as + * devm_free_pages() does. + */ + WARN_ON(devres_release(dev, devm_percpu_release, devm_percpu_match, (__force void *)pdata)); } EXPORT_SYMBOL_GPL(devm_free_percpu); --=20 2.34.1 From nobody Mon Feb 9 07:11:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 B9EB3171653 for ; Tue, 2 Jul 2024 14:53:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932010; cv=none; b=cIMFMsZSm/aNez5vb96vLrkQ9cW3ueoHeSgA5SMTgYkFqMNYtyP//4vT00CVCcZv9+Qe3UnVeqYGM3JdZtvQT7gM7Se1fA2LgK5JcSvT7pXxroSr6yMVEo9fLJEaBuT/x0Xskjz2CvvguPeRXwm69L8BharG5u7/Bgi4dCaq7KQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932010; c=relaxed/simple; bh=n9+OSyY6JVVaHuxEs+OmSQkkojAPnO262eUlmjcpEwo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jWQnX9XZo0aIk4bqy8dpI60E0laOBLlekbrbmZyyxZlq/DqGwJaoMUVu2S20QXozS3sYB1+fbyozOxXIgM5s5d+b8pHa4qJdo63DDWgebm61ItpcQmYvQtWUX87AUe1ekZnoyFjyL4daf8QG2HBwVMRcwrBCS3hkofkTC/o/xDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=hsKC0fkJ; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="hsKC0fkJ" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 462CODAQ019885; Tue, 2 Jul 2024 14:53:21 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=xIP+35kcvwVY+DrSEssdp2NJ vcSiut1rraURdmETjLo=; b=hsKC0fkJ+6KCAYNyoLgkzO1l6IHiWHL8xkoqI0+i 0ognMsOT5wVXKvl9gFIDw9w/sC/DMjTv/Z6ZxNyk4vr8ppiTwlDhDY/2sOvpCx/J 6Uu34+nqvQnRFcmvc2whmvfsD0wJH0UEGWsOD/08tZbcVrusxd9Jg3jluPNer2uS E5HoB/SO3Y4j6bTGOSnszpEd+vSR8eceL4i0cUtQ9+Kr1LNS1kxmKQXn9hBgbGai b7BVO8KQSU9EtO8LgtrASOFt2vGIrzRxJ5nLr1SoBywa0SxxZBB8u30jQmgFr3B0 Cu/FkwGxdg3LqG9Th7nUgqScH8XAwTVEZyacpJmK6GJ+uA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 402ag2gju4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jul 2024 14:53:21 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 462ErLfl006560 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jul 2024 14:53:21 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 2 Jul 2024 07:53:18 -0700 From: Zijun Hu To: CC: , , , , , , Zijun Hu Subject: [PATCH v1 3/5] devres: Initialize an uninitialized struct member Date: Tue, 2 Jul 2024 22:51:52 +0800 Message-ID: <1719931914-19035-4-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: h8HOLRoaAz2KbaAdLQcAywq1VIpZD_YV X-Proofpoint-GUID: h8HOLRoaAz2KbaAdLQcAywq1VIpZD_YV X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-02_10,2024-07-02_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 mlxlogscore=823 bulkscore=0 spamscore=0 priorityscore=1501 suspectscore=0 adultscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407020110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Initialize an uninitialized struct member for driver API devres_open_group(). Signed-off-by: Zijun Hu --- Previous discussion link: https://lore.kernel.org/lkml/1718629765-32720-1-git-send-email-quic_zijuhu@= quicinc.com/ Changes since the original one: - Simplify fix by use =3D instead of memset() and commit message drivers/base/devres.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 8d709dbd4e0c..e9b0d94aeabd 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -567,6 +567,7 @@ void * devres_open_group(struct device *dev, void *id, = gfp_t gfp) grp->id =3D grp; if (id) grp->id =3D id; + grp->color =3D 0; =20 spin_lock_irqsave(&dev->devres_lock, flags); add_dr(dev, &grp->node[0]); --=20 2.34.1 From nobody Mon Feb 9 07:11:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 10C6F1BA883 for ; Tue, 2 Jul 2024 14:53:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932013; cv=none; b=N9FEyX1QJDlCjsw/R2B8kIbsjjIGeBYGxuKWsftcOR2I4sFABcKE+FWZBRhu3FfifbZ99GV2mgLmqP1Q/BIgf6J2E+RsXq8H26tUjLAJ1CotiqZjd2DtPj2mWdN9bsZoroTpSuz4oUtevahOtIvwbHjin7MOZus6YYmc3jBqpxc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932013; c=relaxed/simple; bh=tXlu/iyyiCZQKvXuXEUwC4OSe5RD3diweqj4T7gWl6M=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=iS9A4aWS2Ksqk8Pmuk9p2Ye7wTLRBzQW7hRkKwvgOfgq38wWxrdAkr9Qs8nNCgdj989sF8SbkPDdxsp6g0Ba0A5laiAawFN5nGJie+CWkrc5rXNgW4iTLigfWR8kFePefwmvLd6uQ0lOoH2nivXothNdjfN6vMU8v1oUJ3p1ORc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=g5mPUV4f; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="g5mPUV4f" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 462CYO8J019938; Tue, 2 Jul 2024 14:53:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=sCFEBHA7koj+ik2f1w9lXo1W 2vxNTRhHDG7Av5cWQgU=; b=g5mPUV4fqb3TIrKz6WxQTpVq92TXXAPnNaZ5yy4q RuBMuUMvkNBgUmVsWtopkZ0eTfixqogYMh8VlSImCWBOijStGdUUmkqRKdIh31JF t7jtO2vr9GAfHbjHUtOtGJsQGj4MNM5Je7KWhGGk8wImM7a5/b8KVhAox6UH0Wf2 z5qdnq8WL6Zeq7wW9K4uOpHq/5TFa1E7EDzS0xPlr1R0ohYvWWNZoX+oApZ4F7BI XUKbqzi/3d859mGKhyEnQNQi5JbonlpDaJ313Lg4fxyTtpnO9Jig/dQ8DuxzerM1 NYcguJ6be260QTc84eTQd5+Xo/+otEWAjySpltZyKI4pkg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 40297rrqk2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jul 2024 14:53:24 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA01.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 462ErOjK015041 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jul 2024 14:53:24 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 2 Jul 2024 07:53:22 -0700 From: Zijun Hu To: CC: , , , , , , Zijun Hu Subject: [PATCH v1 4/5] devres: Simplify devm_percpu_match() implementation Date: Tue, 2 Jul 2024 22:51:53 +0800 Message-ID: <1719931914-19035-5-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: KjNgpdRdBidkasdEeyDcc7OjyGbgs3pO X-Proofpoint-GUID: KjNgpdRdBidkasdEeyDcc7OjyGbgs3pO X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-02_10,2024-07-02_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 mlxlogscore=999 lowpriorityscore=0 clxscore=1015 mlxscore=0 suspectscore=0 spamscore=0 adultscore=0 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407020110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Simplify devm_percpu_match() implementation by removing redundant conversions. Signed-off-by: Zijun Hu --- Previous discussion link: https://lore.kernel.org/lkml/1719496036-24642-1-git-send-email-quic_zijuhu@= quicinc.com/ Changes since the original one: - Select the simplier solution drivers/base/devres.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index e9b0d94aeabd..2ad6dacb3472 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -1176,9 +1176,8 @@ static void devm_percpu_release(struct device *dev, v= oid *pdata) =20 static int devm_percpu_match(struct device *dev, void *data, void *p) { - struct devres *devr =3D container_of(data, struct devres, data); - - return *(void **)devr->data =3D=3D p; + /* @data is already and must be (void *)devr->data */ + return *(void **)data =3D=3D p; } =20 /** --=20 2.34.1 From nobody Mon Feb 9 07:11:21 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (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 8AAF11BB6BA for ; Tue, 2 Jul 2024 14:53:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932018; cv=none; b=kJTsADBBDGg/xiJNa37Zlpe90SjJ71sUN2MYWjnlBbqjlQ8cLkpleQXQgSR5Et6KBqtSPjERG00L7irNo5vvKyZpytdbBeI2MkhLOn8fYlrRWhUPqxZP6v/ZcTf4+KDd9ISO3xf0hqYEIiRUHRyh/PiwG9jKL7S6ywu8323sNEQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719932018; c=relaxed/simple; bh=VhEiRl4fKMKCqBZE6aT51QUjJ2GiFpe1+YbrH7G0LCo=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=QlEYT8Mc3/7kJwvo18KZHoDhaGCeFPQJwPey8GFGak4q4mL/cwNLqXgth80ImerXFwUyZ1GB4DZMphevI4l5w6Pz68Iwxbhay/Wn9wf/ROKs7h6GwBEb2GOhEpvWFF7CLes3+ndg2YZ7BgZq/8PdqORFhwBEQYRlTlZ3h+C4LMg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com; spf=pass smtp.mailfrom=quicinc.com; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b=CNoV1nIX; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=quicinc.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=quicinc.com header.i=@quicinc.com header.b="CNoV1nIX" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 462BJtKS007913; Tue, 2 Jul 2024 14:53:29 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=qcppdkim1; bh=3TAnMpQEW3ealwIXvjyJriqo +ARF2Q/tb7yNcaLVCio=; b=CNoV1nIXW5WqZ/1/PP0rboDCAV67ZMt82Bre4nCe JFyZP+3iLgR8A/m3+rPVGM3gdHtLkV+TwSVjXikZCrZMKiPx6h6E20Fh4rVcb8+X nkHY7Wd7hS8fbODe0eINpgALwMi9FOs79u174IliPaBnsJV4muVkTzE6+kO1UAVN ZQNstjv/93j5E9yRO3ud+yEuDNN3RDXUtf1/lCFK7osZTPXfppvuOZQKewy66kxW Dcq25ZSLE/BUOLkQAQkoJfyTSNnHV1tSkr/uBPcuRlqXupoKv+4+9OITeB6MfTcc KXHTgD/VMbF1Rqu/WjRBJtKmLkIgQv84Qp5yePYxxLR3QA== Received: from nasanppmta03.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 402bj88de8-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 02 Jul 2024 14:53:29 +0000 (GMT) Received: from nasanex01a.na.qualcomm.com (nasanex01a.na.qualcomm.com [10.52.223.231]) by NASANPPMTA03.qualcomm.com (8.17.1.19/8.17.1.19) with ESMTPS id 462ErSnS007113 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 2 Jul 2024 14:53:28 GMT Received: from zijuhu-gv.qualcomm.com (10.80.80.8) by nasanex01a.na.qualcomm.com (10.52.223.231) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Tue, 2 Jul 2024 07:53:26 -0700 From: Zijun Hu To: CC: , , , , , , Zijun Hu Subject: [PATCH v1 5/5] devres: Correct code style for functions that return a pointer type Date: Tue, 2 Jul 2024 22:51:54 +0800 Message-ID: <1719931914-19035-6-git-send-email-quic_zijuhu@quicinc.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> References: <1719931914-19035-1-git-send-email-quic_zijuhu@quicinc.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-ClientProxiedBy: nasanex01b.na.qualcomm.com (10.46.141.250) To nasanex01a.na.qualcomm.com (10.52.223.231) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-ORIG-GUID: -nTW5lZfpQm6s81Qt7UMr9PRuCFwuSp8 X-Proofpoint-GUID: -nTW5lZfpQm6s81Qt7UMr9PRuCFwuSp8 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.28.16 definitions=2024-07-02_10,2024-07-02_02,2024-05-17_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 impostorscore=0 spamscore=0 suspectscore=0 mlxlogscore=865 mlxscore=0 priorityscore=1501 malwarescore=0 adultscore=0 bulkscore=0 phishscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2406140001 definitions=main-2407020110 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Correct code style for several functions that return a pointer type. Signed-off-by: Zijun Hu --- drivers/base/devres.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/base/devres.c b/drivers/base/devres.c index 2ad6dacb3472..be82d2d71544 100644 --- a/drivers/base/devres.c +++ b/drivers/base/devres.c @@ -85,7 +85,7 @@ static void group_close_release(struct device *dev, void = *res) /* noop */ } =20 -static struct devres_group * node_to_group(struct devres_node *node) +static struct devres_group *node_to_group(struct devres_node *node) { if (node->release =3D=3D &group_open_release) return container_of(node, struct devres_group, node[0]); @@ -107,8 +107,8 @@ static bool check_dr_size(size_t size, size_t *tot_size) return true; } =20 -static __always_inline struct devres * alloc_dr(dr_release_t release, - size_t size, gfp_t gfp, int nid) +static __always_inline struct devres *alloc_dr(dr_release_t release, + size_t size, gfp_t gfp, int nid) { size_t tot_size; struct devres *dr; @@ -283,8 +283,8 @@ static struct devres *find_dr(struct device *dev, dr_re= lease_t release, * RETURNS: * Pointer to found devres, NULL if not found. */ -void * devres_find(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data) +void *devres_find(struct device *dev, dr_release_t release, + dr_match_t match, void *match_data) { struct devres *dr; unsigned long flags; @@ -313,8 +313,8 @@ EXPORT_SYMBOL_GPL(devres_find); * RETURNS: * Pointer to found or added devres. */ -void * devres_get(struct device *dev, void *new_res, - dr_match_t match, void *match_data) +void *devres_get(struct device *dev, void *new_res, + dr_match_t match, void *match_data) { struct devres *new_dr =3D container_of(new_res, struct devres, data); struct devres *dr; @@ -349,8 +349,8 @@ EXPORT_SYMBOL_GPL(devres_get); * RETURNS: * Pointer to removed devres on success, NULL if not found. */ -void * devres_remove(struct device *dev, dr_release_t release, - dr_match_t match, void *match_data) +void *devres_remove(struct device *dev, dr_release_t release, + dr_match_t match, void *match_data) { struct devres *dr; unsigned long flags; @@ -549,7 +549,7 @@ int devres_release_all(struct device *dev) * RETURNS: * ID of the new group, NULL on failure. */ -void * devres_open_group(struct device *dev, void *id, gfp_t gfp) +void *devres_open_group(struct device *dev, void *id, gfp_t gfp) { struct devres_group *grp; unsigned long flags; @@ -577,7 +577,7 @@ void * devres_open_group(struct device *dev, void *id, = gfp_t gfp) EXPORT_SYMBOL_GPL(devres_open_group); =20 /* Find devres group with ID @id. If @id is NULL, look for the latest. */ -static struct devres_group * find_group(struct device *dev, void *id) +static struct devres_group *find_group(struct device *dev, void *id) { struct devres_node *node; =20 --=20 2.34.1