* [PATCH] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()
@ 2022-01-16 4:35 xkernel.wang
0 siblings, 0 replies; 3+ messages in thread
From: xkernel.wang @ 2022-01-16 4:35 UTC (permalink / raw)
To: peda; +Cc: wsa+renesas, linux-i2c, linux-kernel, Xiaoke Wang
From: Xiaoke Wang <xkernel.wang@foxmail.com>
devm_kstrdup() returns pointer to allocated string on success,
NULL on failure. So it is better to check the return value of it.
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
drivers/i2c/muxes/i2c-demux-pinctrl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 5365199..3203361 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -243,6 +243,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL);
props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
+ if (!props[i].name || !props[i].value) {
+ err = -ENOMEM;
+ goto err_rollback;
+ }
props[i].length = 3;
of_changeset_init(&priv->chan[i].chgset);
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()
2022-03-03 12:39 xkernel.wang
@ 2023-09-20 21:30 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2023-09-20 21:30 UTC (permalink / raw)
To: xkernel.wang; +Cc: peda, linux-i2c, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 360 bytes --]
On Thu, Mar 03, 2022 at 08:39:14PM +0800, xkernel.wang@foxmail.com wrote:
> From: Xiaoke Wang <xkernel.wang@foxmail.com>
>
> devm_kstrdup() returns pointer to allocated string on success,
> NULL on failure. So it is better to check the return value of it.
>
> Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
Applied to for-current, thanks!
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()
@ 2022-03-03 12:39 xkernel.wang
2023-09-20 21:30 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: xkernel.wang @ 2022-03-03 12:39 UTC (permalink / raw)
To: wsa+renesas, peda; +Cc: linux-i2c, linux-kernel, Xiaoke Wang
From: Xiaoke Wang <xkernel.wang@foxmail.com>
devm_kstrdup() returns pointer to allocated string on success,
NULL on failure. So it is better to check the return value of it.
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
drivers/i2c/muxes/i2c-demux-pinctrl.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/i2c/muxes/i2c-demux-pinctrl.c b/drivers/i2c/muxes/i2c-demux-pinctrl.c
index 5365199..3203361 100644
--- a/drivers/i2c/muxes/i2c-demux-pinctrl.c
+++ b/drivers/i2c/muxes/i2c-demux-pinctrl.c
@@ -243,6 +243,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL);
props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
+ if (!props[i].name || !props[i].value) {
+ err = -ENOMEM;
+ goto err_rollback;
+ }
props[i].length = 3;
of_changeset_init(&priv->chan[i].chgset);
--
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-09-20 21:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-16 4:35 [PATCH] i2c: mux: demux-pinctrl: check the return value of devm_kstrdup() xkernel.wang
2022-03-03 12:39 xkernel.wang
2023-09-20 21:30 ` Wolfram Sang
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.