Unverified Commit b72cfb22 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!8167 v2 mmc: sdio: fix possible resource leaks in some error paths

parents c9c6dfb9 58915ae4
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -294,6 +294,12 @@ static void sdio_release_func(struct device *dev)

	sdio_free_func_cis(func);

	/*
	 * We have now removed the link to the tuples in the
	 * card structure, so remove the reference.
	 */
	put_device(&func->card->dev);

	kfree(func->info);
	kfree(func->tmpbuf);
	kfree(func);
@@ -324,6 +330,12 @@ struct sdio_func *sdio_alloc_func(struct mmc_card *card)

	device_initialize(&func->dev);

	/*
	 * We may link to tuples in the card structure,
	 * we need make sure we have a reference to it.
	 */
	get_device(&func->card->dev);

	func->dev.parent = &card->dev;
	func->dev.bus = &sdio_bus_type;
	func->dev.release = sdio_release_func;
@@ -377,10 +389,9 @@ int sdio_add_func(struct sdio_func *func)
 */
void sdio_remove_func(struct sdio_func *func)
{
	if (!sdio_func_present(func))
		return;

	if (sdio_func_present(func))
		device_del(&func->dev);

	of_node_put(func->dev.of_node);
	put_device(&func->dev);
}
+0 −12
Original line number Diff line number Diff line
@@ -391,12 +391,6 @@ int sdio_read_func_cis(struct sdio_func *func)
	if (ret)
		return ret;

	/*
	 * Since we've linked to tuples in the card structure,
	 * we must make sure we have a reference to it.
	 */
	get_device(&func->card->dev);

	/*
	 * Vendor/device id is optional for function CIS, so
	 * copy it from the card structure as needed.
@@ -422,11 +416,5 @@ void sdio_free_func_cis(struct sdio_func *func)
	}

	func->tuples = NULL;

	/*
	 * We have now removed the link to the tuples in the
	 * card structure, so remove the reference.
	 */
	put_device(&func->card->dev);
}