linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH clk v2] clk: clkdev: add error messages for name exceeding maximum length
@ 2024-03-14  2:39 Duanqiang Wen
  2024-03-14  8:42 ` Russell King (Oracle)
  0 siblings, 1 reply; 2+ messages in thread
From: Duanqiang Wen @ 2024-03-14  2:39 UTC (permalink / raw)
  To: mturquette, sboyd, linux, linux-clk, linux-kernel,
	linux-arm-kernel
  Cc: Duanqiang Wen

if one device register clkdev with dev_id or con_id
greater than maximum length, clkdev_create functions
will not return err, but clk_find functions will not
match the device, it's difficult to identify issues
for developers.So add error messages for dev_id greater
than 20 characters and con_id greater than 16 characters.

eg. clkdev_create(clk, NULL, "i2c_designware.16796")
it will create clk_lookup with dev_id "i2c_designware.1679",
because clk_name exceeds dev_id maximum, but clkdev_create not
return err. when driver call clk_find functions, use "i2c_desig
nware.16796" to find clk, it will return failed,but I don't know
where the problem is. It took a long time to find the problem.

Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>
---
 drivers/clk/clkdev.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index ee37d0be6877..2d24ea232dc7 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -165,11 +165,21 @@ vclkdev_alloc(struct clk_hw *hw, const char *con_id, const char *dev_fmt,
 
 	cla->cl.clk_hw = hw;
 	if (con_id) {
+		if (strlen(dev_fmt) >= MAX_CON_ID) {
+			pr_err("%s:con_id cannot be greater than %d characters\n",
+					dev_fmt, MAX_CON_ID);
+			return NULL;
+		}
 		strscpy(cla->con_id, con_id, sizeof(cla->con_id));
 		cla->cl.con_id = cla->con_id;
 	}
 
 	if (dev_fmt) {
+		if (strlen(dev_fmt) >= MAX_DEV_ID) {
+			pr_err("%s:dev_id cannot be greater than %d characters\n",
+					dev_fmt, MAX_DEV_ID);
+			return NULL;
+		}
 		vscnprintf(cla->dev_id, sizeof(cla->dev_id), dev_fmt, ap);
 		cla->cl.dev_id = cla->dev_id;
 	}
-- 
2.27.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH clk v2] clk: clkdev: add error messages for name exceeding maximum length
  2024-03-14  2:39 [PATCH clk v2] clk: clkdev: add error messages for name exceeding maximum length Duanqiang Wen
@ 2024-03-14  8:42 ` Russell King (Oracle)
  0 siblings, 0 replies; 2+ messages in thread
From: Russell King (Oracle) @ 2024-03-14  8:42 UTC (permalink / raw)
  To: Duanqiang Wen
  Cc: mturquette, sboyd, linux-clk, linux-kernel, linux-arm-kernel

On Thu, Mar 14, 2024 at 10:39:09AM +0800, Duanqiang Wen wrote:
> if one device register clkdev with dev_id or con_id
> greater than maximum length, clkdev_create functions
> will not return err, but clk_find functions will not
> match the device, it's difficult to identify issues
> for developers.So add error messages for dev_id greater
> than 20 characters and con_id greater than 16 characters.
> 
> eg. clkdev_create(clk, NULL, "i2c_designware.16796")
> it will create clk_lookup with dev_id "i2c_designware.1679",
> because clk_name exceeds dev_id maximum, but clkdev_create not
> return err. when driver call clk_find functions, use "i2c_desig
> nware.16796" to find clk, it will return failed,but I don't know
> where the problem is. It took a long time to find the problem.
> 
> Signed-off-by: Duanqiang Wen <duanqiangwen@net-swift.com>

This looks like v1 just reposted with a v2 tag. I don't see any obvious
changes in the patch.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-14  8:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-14  2:39 [PATCH clk v2] clk: clkdev: add error messages for name exceeding maximum length Duanqiang Wen
2024-03-14  8:42 ` Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).