ANDROID: extcon: fix allocation for edev->bnh

Since the device_register() call was moved later in the function by the
upstream commit 6e721f3ad0 ("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: 6e721f3ad0 ("extcon: Modify extcon device to be created after driver data is set")
Signed-off-by: Will McVicker <willmcvicker@google.com>
Change-Id: Ie997bbe31c84c7acc779043d7f91cfa798082c9f
This commit is contained in:
Will McVicker
2022-06-29 11:43:39 -07:00
committed by Haky86
parent 1b98b0c602
commit abccdba467

View File

@@ -1317,8 +1317,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;
@@ -1335,7 +1334,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);
@@ -1344,6 +1343,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);
@@ -1410,6 +1411,7 @@ void extcon_dev_unregister(struct extcon_dev *edev)
kfree(edev->cables);
kfree(edev->nh);
}
kfree(edev->bnh);
put_device(&edev->dev);
}