From abccdba4677e8d72dd5eff6960e649f67038b989 Mon Sep 17 00:00:00 2001 From: Will McVicker Date: Wed, 29 Jun 2022 11:43:39 -0700 Subject: [PATCH] ANDROID: extcon: fix allocation for edev->bnh Since the device_register() call was moved later in the function by the upstream commit 6e721f3ad0535 ("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: 6e721f3ad0535 ("extcon: Modify extcon device to be created after driver data is set") Signed-off-by: Will McVicker Change-Id: Ie997bbe31c84c7acc779043d7f91cfa798082c9f --- drivers/extcon/extcon.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 004c7cbc37ab..3c63e5139933 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -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); }