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

!15329 Fix CVE-2022-49308

Merge Pull Request from: @ci-robot 
 
PR sync from: Hongbo Li <lihongbo22@huawei.com>
https://mailweb.openeuler.org/archives/list/kernel@openeuler.org/message/J6ZNHEGDJV64TVWWYJ73EGQ566NWUAMG/ 
Fix CVE-2022-49308.

Dinghao Liu (1):
  extcon: Fix error handling in extcon_dev_register

bumwoo lee (1):
  extcon: Modify extcon device to be created after driver data is set

 
https://gitee.com/src-openeuler/kernel/issues/IBP2KJ 
 
Link:https://gitee.com/openeuler/kernel/pulls/15329

 

Reviewed-by: default avatarZhang Jianhua <chris.zjh@huawei.com>
Reviewed-by: default avatarYuan Can <yuancan@huawei.com>
Signed-off-by: default avatarYuan Can <yuancan@huawei.com>
parents ddf40425 69973c89
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -1245,18 +1245,14 @@ int extcon_dev_register(struct extcon_dev *edev)
		edev->dev.type = &edev->extcon_dev_type;
	}

	ret = device_register(&edev->dev);
	if (ret) {
		put_device(&edev->dev);
		goto err_dev;
	}

	spin_lock_init(&edev->lock);
	edev->nh = devm_kcalloc(&edev->dev, edev->max_supported,
				sizeof(*edev->nh), GFP_KERNEL);
	if (edev->max_supported) {
		edev->nh = kcalloc(edev->max_supported, sizeof(*edev->nh),
				GFP_KERNEL);
		if (!edev->nh) {
			ret = -ENOMEM;
		goto err_dev;
			goto err_alloc_nh;
		}
	}

	for (index = 0; index < edev->max_supported; index++)
@@ -1267,6 +1263,12 @@ int extcon_dev_register(struct extcon_dev *edev)
	dev_set_drvdata(&edev->dev, edev);
	edev->state = 0;

	ret = device_register(&edev->dev);
	if (ret) {
		put_device(&edev->dev);
		goto err_dev;
	}

	mutex_lock(&extcon_dev_list_lock);
	list_add(&edev->entry, &extcon_dev_list);
	mutex_unlock(&extcon_dev_list_lock);
@@ -1274,6 +1276,9 @@ int extcon_dev_register(struct extcon_dev *edev)
	return 0;

err_dev:
	if (edev->max_supported)
		kfree(edev->nh);
err_alloc_nh:
	if (edev->max_supported)
		kfree(edev->extcon_dev_type.groups);
err_alloc_groups:
@@ -1334,6 +1339,7 @@ void extcon_dev_unregister(struct extcon_dev *edev)
	if (edev->max_supported) {
		kfree(edev->extcon_dev_type.groups);
		kfree(edev->cables);
		kfree(edev->nh);
	}

	put_device(&edev->dev);