Skip to content

Commit

Permalink
visorbus: fix error return code in visorchipset_init()
Browse files Browse the repository at this point in the history
[ 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>
  • Loading branch information
Zhen Lei authored and gregkh committed Jul 14, 2021
1 parent e5a3a31 commit bd95a3e
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/visorbus/visorchipset.c
Original file line number Diff line number Diff line change
Expand Up @@ -1561,7 +1561,7 @@ static void controlvm_periodic_work(struct work_struct *work)

static int visorchipset_init(struct acpi_device *acpi_device)
{
int err = -ENODEV;
int err = -ENOMEM;
struct visorchannel *controlvm_channel;

chipset_dev = kzalloc(sizeof(*chipset_dev), GFP_KERNEL);
Expand All @@ -1584,8 +1584,10 @@ static int visorchipset_init(struct acpi_device *acpi_device)
"controlvm",
sizeof(struct visor_controlvm_channel),
VISOR_CONTROLVM_CHANNEL_VERSIONID,
VISOR_CHANNEL_SIGNATURE))
VISOR_CHANNEL_SIGNATURE)) {
err = -ENODEV;
goto error_delete_groups;
}
/* if booting in a crash kernel */
if (is_kdump_kernel())
INIT_DELAYED_WORK(&chipset_dev->periodic_controlvm_work,
Expand Down

0 comments on commit bd95a3e

Please sign in to comment.