Skip to contentSkip to conversation

checkpatch: Add devres_alloc() to allocation functions

PATCH In review [email protected] 3 participants 6 messages Aug 12 – Aug 22

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 checkpatch: Add devres_alloc() to allocation functions

From: bui duc phuc <[email protected]>

Add devres_alloc() and devres_alloc_node() to $allocFunctions so checkpatch.pl can detect unnecessary out-of-memory messages following a failed allocation.

---

Link v1:
https://lore.kernel.org/all/[email protected]/
Changes in v2:
- Add devres_alloc_node() to $allocFunctions.
- Update the commit message.

 scripts/checkpatch.pl | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +2 -1
index 2b7a42bbdd94..e89cbc3f2604 100755
@@ -644,7 +644,8 @@ our $allocFunctions = qr{(?x:
 		kmemdup(?:_nul)?) |
 	(?:\w+)?alloc_skb(?:_ip_align)? |
 				# dev_alloc_skb/netdev_alloc_skb, et al
-	dma_alloc_coherent
+	dma_alloc_coherent |
+	devres_alloc(?:_node)?
 )};
 
 our $signature_tags = qr{(?xi:
Signature · 1 line
2.43.0
#1 lore raw

PATCH 2/3 thermal: hwmon: Remove redundant OOM message

From: bui duc phuc <[email protected]>

Remove the dev_warn() after a failed devres_alloc(). This is consistent with checkpatch's OOM_MESSAGE convention: no error message is needed after a kzalloc()-style allocation failure.

---
 drivers/thermal/thermal_hwmon.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/thermal/thermal_hwmon.c +1 -3
index ec73d03a1e60..747ac87d1c37 100644
@@ -269,10 +269,8 @@ int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device
 
 	ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
 			   GFP_KERNEL);
-	if (!ptr) {
-		dev_warn(dev, "Failed to allocate device resource data\n");
+	if (!ptr)
 		return -ENOMEM;
-	}
 
 	ret = thermal_add_hwmon_sysfs(tz);
 	if (ret) {
Signature · 1 line
2.43.0
maintainer Acked-by on v1 2/3
#2 lore raw

Re: [PATCH 2/3] thermal: hwmon: Remove redundant OOM message

Quoted 8 lines · On Wed, Aug 12, 2026 at 6:29 AM <[email protected]> wrote:

From: bui duc phuc <[email protected]>

Remove the dev_warn() after a failed devres_alloc(). This is consistent with checkpatch's OOM_MESSAGE convention: no error message is needed after a kzalloc()-style allocation failure.

and I'm assuming that this will be routed along with the rest of the series.

Thanks!

Quoted 23 lines
---
 drivers/thermal/thermal_hwmon.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/thermal/thermal_hwmon.c +1 -4
index ec73d03a1e60..747ac87d1c37 100644
@@ -269,10 +269,8 @@ int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device
 
        ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
                           GFP_KERNEL);
-       if (!ptr) {
-               dev_warn(dev, "Failed to allocate device resource data\n");
+       if (!ptr)
                return -ENOMEM;
-       }
 
        ret = thermal_add_hwmon_sysfs(tz);
        if (ret) {
--

2.43.0

Acked-by on v1 2/3
#3 lore raw

Re: [PATCH 2/3] thermal: hwmon: Remove redundant OOM message

In reply to [email protected]
Quoted 16 lines · On 8/12/26 06:28, [email protected] wrote:

From: bui duc phuc <[email protected]>

Remove the dev_warn() after a failed devres_alloc(). This is consistent with checkpatch's OOM_MESSAGE convention: no error message is needed after a kzalloc()-style allocation failure.

---
  drivers/thermal/thermal_hwmon.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)
drivers/thermal/thermal_hwmon.c +0 -0
index ec73d03a1e60..747ac87d1c37 100644

drivers/thermal/thermal_hwmon.c int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device · line 275

Quoted 8 lines
drivers/thermal/thermal_hwmon.c +1 -3
@@ -269,10 +269,8 @@ int devm_thermal_add_hwmon_sysfs(struct device *dev, struct thermal_zone_device
 
  	ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
  			   GFP_KERNEL);
-	if (!ptr) {
-		dev_warn(dev, "Failed to allocate device resource data\n");
+	if (!ptr)
  		return -ENOMEM;
-	}
#4 lore raw

Re: [PATCH 2/3] thermal: hwmon: Remove redundant OOM message

Hi Rafael and Daniel,

Thanks for your reviews and Acks.

Best regards,
Phuc

#5 lore raw

PATCH 3/3 usb: phy: Remove redundant OOM message

In reply to [email protected]

From: bui duc phuc <[email protected]>

Remove the dev_dbg() after a failed devres_alloc(). This is consistent with checkpatch's OOM_MESSAGE convention: no error message is needed after a kzalloc()-style allocation failure.

---
 drivers/usb/phy/phy.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/usb/phy/phy.c +1 -3
index 5a9b9353f343..117a33fa9e91 100644
@@ -534,10 +534,8 @@ struct  usb_phy *devm_usb_get_phy_by_node(struct device *dev,
 	unsigned long	flags;
 
 	ptr = devres_alloc(devm_usb_phy_release2, sizeof(*ptr), GFP_KERNEL);
-	if (!ptr) {
-		dev_dbg(dev, "failed to allocate memory for devres\n");
+	if (!ptr)
 		goto err0;
-	}
 
 	spin_lock_irqsave(&phy_lock, flags);
 
Signature · 1 line
2.43.0