* [PATCH] checkpatch: Add devres_alloc() to allocation functions
@ 2026-08-12 2:43 phucduc.bui
2026-08-12 2:55 ` Joe Perches
0 siblings, 1 reply; 3+ messages in thread
From: phucduc.bui @ 2026-08-12 2:43 UTC (permalink / raw)
To: Andy Whitcroft, Joe Perches, linux-kernel; +Cc: bui duc phuc
From: bui duc phuc <phucduc.bui@gmail.com>
Add devres_alloc() to $allocFunctions so checkpatch.pl can detect
unnecessary out-of-memory messages following a failed allocation.
Signed-off-by: bui duc phuc <phucduc.bui@gmail.com>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 2b7a42bbdd94..df042d31ff1f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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
)};
our $signature_tags = qr{(?xi:
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: Add devres_alloc() to allocation functions
2026-08-12 2:43 [PATCH] checkpatch: Add devres_alloc() to allocation functions phucduc.bui
@ 2026-08-12 2:55 ` Joe Perches
2026-08-12 3:51 ` Bui Duc Phuc
0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2026-08-12 2:55 UTC (permalink / raw)
To: phucduc.bui, Andy Whitcroft, linux-kernel
On Wed, 2026-08-12 at 09:43 +0700, phucduc.bui@gmail.com wrote:
> Add devres_alloc() to $allocFunctions so checkpatch.pl can detect
> unnecessary out-of-memory messages following a failed allocation.
OK, are you also updating the 2 existing instances where
there is an OOM message?
-----------
drivers/thermal/thermal_hwmon.c: ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
drivers/thermal/thermal_hwmon.c- GFP_KERNEL);
drivers/thermal/thermal_hwmon.c- if (!ptr) {
drivers/thermal/thermal_hwmon.c- dev_warn(dev, "Failed to allocate device resource data\n");
drivers/thermal/thermal_hwmon.c- return -ENOMEM;
drivers/thermal/thermal_hwmon.c- }
-----------
drivers/usb/phy/phy.c: ptr = devres_alloc(devm_usb_phy_release2, sizeof(*ptr), GFP_KERNEL);
drivers/usb/phy/phy.c- if (!ptr) {
drivers/usb/phy/phy.c- dev_dbg(dev, "failed to allocate memory for devres\n");
drivers/usb/phy/phy.c- goto err0;
drivers/usb/phy/phy.c- }
-----------
What about devres_alloc_node? (there aren't any OOM messages)
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> @@ -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
> )};
>
> our $signature_tags = qr{(?xi:
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] checkpatch: Add devres_alloc() to allocation functions
2026-08-12 2:55 ` Joe Perches
@ 2026-08-12 3:51 ` Bui Duc Phuc
0 siblings, 0 replies; 3+ messages in thread
From: Bui Duc Phuc @ 2026-08-12 3:51 UTC (permalink / raw)
To: Joe Perches; +Cc: Andy Whitcroft, linux-kernel
Hi Joe,
Thank you for your review.
>
> OK, are you also updating the 2 existing instances where
> there is an OOM message?
>
> -----------
> drivers/thermal/thermal_hwmon.c: ptr = devres_alloc(devm_thermal_hwmon_release, sizeof(*ptr),
> drivers/thermal/thermal_hwmon.c- GFP_KERNEL);
> drivers/thermal/thermal_hwmon.c- if (!ptr) {
> drivers/thermal/thermal_hwmon.c- dev_warn(dev, "Failed to allocate device resource data\n");
> drivers/thermal/thermal_hwmon.c- return -ENOMEM;
> drivers/thermal/thermal_hwmon.c- }
> -----------
> drivers/usb/phy/phy.c: ptr = devres_alloc(devm_usb_phy_release2, sizeof(*ptr), GFP_KERNEL);
> drivers/usb/phy/phy.c- if (!ptr) {
> drivers/usb/phy/phy.c- dev_dbg(dev, "failed to allocate memory for devres\n");
> drivers/usb/phy/phy.c- goto err0;
> drivers/usb/phy/phy.c- }
> -----------
>
> What about devres_alloc_node? (there aren't any OOM messages)
>
I'll send a v2 patch series addressing your comments.
Best regards,
Phuc
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-08-12 3:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-12 2:43 [PATCH] checkpatch: Add devres_alloc() to allocation functions phucduc.bui
2026-08-12 2:55 ` Joe Perches
2026-08-12 3:51 ` Bui Duc Phuc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox