Skip to content

Commit 4ebcbda

Browse files
Zhen Leismb49
authored andcommitted
visorbus: fix error return code in visorchipset_init()
BugLink: https://bugs.launchpad.net/bugs/1938199 [ Upstream commit ce52ec5 ] Commit 1366a3d ("staging: unisys: visorbus: visorchipset_init clean up gotos") assigns the initial value -ENODEV to the local variable 'err', and the first several error branches will return this value after "goto error". But commit f1f537c ("staging: unisys: visorbus: Consolidate controlvm channel creation.") overwrites 'err' in the middle of the way. As a result, some error branches do not successfully return the initial value -ENODEV of 'err', but return 0. In addition, when kzalloc() fails, -ENOMEM should be returned instead of -ENODEV. Fixes: f1f537c ("staging: unisys: visorbus: Consolidate controlvm channel creation.") Reported-by: Hulk Robot <hulkci@huawei.com> Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Link: https://lore.kernel.org/r/20210528082614.9337-1-thunder.leizhen@huawei.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Kamal Mostafa <kamal@canonical.com> Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
1 parent f55846f commit 4ebcbda

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/visorbus/visorchipset.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,7 +1561,7 @@ static void controlvm_periodic_work(struct work_struct *work)
15611561

15621562
static int visorchipset_init(struct acpi_device *acpi_device)
15631563
{
1564-
int err = -ENODEV;
1564+
int err = -ENOMEM;
15651565
struct visorchannel *controlvm_channel;
15661566

15671567
chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL);
@@ -1584,8 +1584,10 @@ static int visorchipset_init(struct acpi_device *acpi_device)
15841584
"controlvm",
15851585
sizeof(struct visor_controlvm_channel),
15861586
VISOR_CONTROLVM_CHANNEL_VERSIONID,
1587-
VISOR_CHANNEL_SIGNATURE))
1587+
VISOR_CHANNEL_SIGNATURE)) {
1588+
err = -ENODEV;
15881589
goto error_delete_groups;
1590+
}
15891591
/* if booting in a crash kernel */
15901592
if (is_kdump_kernel())
15911593
INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work,

0 commit comments

Comments
 (0)