]> 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)
commit7012e9981c431bd7065c1cff1fc39ffcd473f2e5
treec49610a94f3441db14a384ee2c8d533707781e9c
parent582d2c8ad7c35bf50d710032a79d24e02b2fdc9f
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