Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 926e3eb3 authored by Will McVicker's avatar Will McVicker
Browse files

ANDROID: extcon: fix allocation for edev->bnh



Since the device_register() call was moved later in the function by the
upstream commit cb81ea99 ("extcon: Modify extcon device to be
created after driver data is set"), we need to update the edev->bnh
allocation from devm_kzalloc -> kzalloc. Also, add the kfree for this
allocation accordingly.

Fixes: cb81ea99 ("extcon: Modify extcon device to be created after driver data is set")
Signed-off-by: default avatarWill McVicker <willmcvicker@google.com>
Change-Id: Ie997bbe31c84c7acc779043d7f91cfa798082c9f
parent 9e9f3a4f
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
@@ -1302,8 +1302,7 @@ int extcon_dev_register(struct extcon_dev *edev)
		}
	}

	edev->bnh = devm_kzalloc(&edev->dev,
			sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL);
	edev->bnh = kzalloc(sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL);
	if (!edev->bnh) {
		ret = -ENOMEM;
		goto err_dev;
@@ -1320,7 +1319,7 @@ int extcon_dev_register(struct extcon_dev *edev)
	ret = device_register(&edev->dev);
	if (ret) {
		put_device(&edev->dev);
		goto err_dev;
		goto err_reg;
	}

	mutex_lock(&extcon_dev_list_lock);
@@ -1329,6 +1328,8 @@ int extcon_dev_register(struct extcon_dev *edev)

	return 0;

err_reg:
	kfree(edev->bnh);
err_dev:
	if (edev->max_supported)
		kfree(edev->nh);
@@ -1395,6 +1396,7 @@ void extcon_dev_unregister(struct extcon_dev *edev)
		kfree(edev->cables);
		kfree(edev->nh);
	}
	kfree(edev->bnh);

	put_device(&edev->dev);
}