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

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

parents c1b75f4f a0de6e07
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -266,6 +266,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);
@@ -296,6 +302,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;
@@ -349,10 +361,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
@@ -378,12 +378,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.
@@ -409,11 +403,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);
}