Skip to content

Commit 7c0195f

Browse files
x2018wsakernel
authored andcommitted
i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()
devm_kstrdup() returns pointer to allocated string on success, NULL on failure. So it is better to check the return value of it. Fixes: e35478e ("i2c: mux: demux-pinctrl: run properly with multiple instances") Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com> Signed-off-by: Wolfram Sang <wsa@kernel.org>
1 parent 2409205 commit 7c0195f

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

drivers/i2c/muxes/i2c-demux-pinctrl.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,10 @@ static int i2c_demux_pinctrl_probe(struct platform_device *pdev)
243243

244244
props[i].name = devm_kstrdup(&pdev->dev, "status", GFP_KERNEL);
245245
props[i].value = devm_kstrdup(&pdev->dev, "ok", GFP_KERNEL);
246+
if (!props[i].name || !props[i].value) {
247+
err = -ENOMEM;
248+
goto err_rollback;
249+
}
246250
props[i].length = 3;
247251

248252
of_changeset_init(&priv->chan[i].chgset);

0 commit comments

Comments
 (0)