checkpatch: Add devres_alloc() to allocation functions
Subsystems (3)
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
@@ -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
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
@@ -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
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
@@ -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
Re: [PATCH 2/3] thermal: hwmon: Remove redundant OOM message
In reply to [email protected]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 faileddevres_alloc(). This is consistent with checkpatch'sOOM_MESSAGEconvention: no error message is needed after a kzalloc()-style allocation failure.Signed-off-by bui duc phuc <[email protected]>
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@@ -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
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 faileddevres_alloc(). This is consistent with checkpatch'sOOM_MESSAGEconvention: no error message is needed after a kzalloc()-style allocation failure.Signed-off-by bui duc phuc <[email protected]>--- drivers/thermal/thermal_hwmon.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)drivers/thermal/thermal_hwmon.c +0
-0
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 ; - }
Re: [PATCH 2/3] thermal: hwmon: Remove redundant OOM message
Hi Rafael and Daniel,
Thanks for your reviews and Acks.
Best regards,
Phuc