Skip to content

Commit

Permalink
i2c: mux: demux-pinctrl: check the return value of devm_kstrdup()
Browse files Browse the repository at this point in the history
[ Upstream commit 7c0195f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
x2018 authored and gregkh committed Oct 6, 2023
1 parent 50a096a commit 976c8c1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/i2c/muxes/i2c-demux-pinctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 976c8c1

Please sign in to comment.