Skip to contentSkip to conversation

i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()

PATCH Applied [email protected] 2 participants 2 messages Mar 3, 2022 – Sep 20, 2023

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

PATCH 1/1 i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()

From: Xiaoke Wang <[email protected]>

devm_kstrdup() returns pointer to allocated string on success, NULL on failure. So it is better to check the return value of it.

---
 drivers/i2c/muxes/i2c-demux-pinctrl.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/i2c/muxes/i2c-demux-pinctrl.c +4 -0
index 5365199..3203361 100644
@@ -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);