]> git.baikalelectronics.ru Git - kernel.git/commit
iscsi-target: Fix leak on failure in iscsi_copy_param_list()
authorJesper Juhl <jj@chaosbits.net>
Tue, 2 Aug 2011 08:26:36 +0000 (10:26 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Mon, 22 Aug 2011 19:26:16 +0000 (19:26 +0000)
commit07804ca855fd9bc19f489525804ed9bd0e849f00
treec49610a94f3441db14a384ee2c8d533707781e9c
parentdd652a3b43f5ac60f293d5483b6a5f009f68f4b6
iscsi-target: Fix leak on failure in iscsi_copy_param_list()

We leak memory if the allocations for 'new_param->name' or
'new_param->value' fail in iscsi_target_parameters.c::iscsi_copy_param_list()

We also do a lot of variable assignments that are completely pointless
if the allocations fail.

So, let's move the allocations before the assignments and also make
sure that we free whatever was allocated to one if the allocation fail.

There's also some small CodingStyle fixups in there (curly braces on
both branches of if statement, only one variable per line) since I was
in the area anyway. And finally, error messages in the function are
put on a single line for easy grep'abillity.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_parameters.c