Commit b424f73b authored by Wang Hai's avatar Wang Hai Committed by Stephen Boyd
Browse files

clk: lmk04832: fix return value check in lmk04832_probe()



In case of error, the function devm_kzalloc() and devm_kcalloc() return
NULL pointer not ERR_PTR(). The IS_ERR() test in the return value check
should be replaced with NULL test.

Fixes: 3bc61cfd ("clk: add support for the lmk04832")
Reported-by: default avatarHulk Robot <hulkci@huawei.com>
Signed-off-by: default avatarWang Hai <wanghai38@huawei.com>
Link: https://lore.kernel.org/r/20210630020322.2555946-1-wanghai38@huawei.com


Reviewed-by: default avatarLiam Beguin <lvb@xiphos.com>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
parent b1f24771
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -1425,23 +1425,23 @@ static int lmk04832_probe(struct spi_device *spi)

	lmk->dclk = devm_kcalloc(lmk->dev, info->num_channels >> 1,
				 sizeof(struct lmk_dclk), GFP_KERNEL);
	if (IS_ERR(lmk->dclk)) {
		ret = PTR_ERR(lmk->dclk);
	if (!lmk->dclk) {
		ret = -ENOMEM;
		goto err_disable_oscin;
	}

	lmk->clkout = devm_kcalloc(lmk->dev, info->num_channels,
				   sizeof(*lmk->clkout), GFP_KERNEL);
	if (IS_ERR(lmk->clkout)) {
		ret = PTR_ERR(lmk->clkout);
	if (!lmk->clkout) {
		ret = -ENOMEM;
		goto err_disable_oscin;
	}

	lmk->clk_data = devm_kzalloc(lmk->dev, struct_size(lmk->clk_data, hws,
							   info->num_channels),
				     GFP_KERNEL);
	if (IS_ERR(lmk->clk_data)) {
		ret = PTR_ERR(lmk->clk_data);
	if (!lmk->clk_data) {
		ret = -ENOMEM;
		goto err_disable_oscin;
	}