Skip to content

Commit

Permalink
efi/efi_test: Use memdup_user() as a cleanup
Browse files Browse the repository at this point in the history
Fix coccicheck warning which recommends to use memdup_user().

This patch fixes the following coccicheck warnings:

  drivers/firmware/efi/test/efi_test.c:269:8-15: WARNING opportunity for memdup_user

Signed-off-by: Ivan Hu <ivan.hu@canonical.com>
Signed-off-by: Matt Fleming <matt@codeblueprint.co.uk>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Ivan Khoronzhuk <ivan.khoronzhuk@linaro.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-efi@vger.kernel.org
Link: http://lkml.kernel.org/r/20161018143318.15673-7-matt@codeblueprint.co.uk
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ivan Hu authored and Ingo Molnar committed Oct 18, 2016
1 parent 9c30a21 commit c208ed9
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions drivers/firmware/efi/test/efi_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,10 @@ static long efi_runtime_set_variable(unsigned long arg)
return rv;
}

data = kmalloc(setvariable.data_size, GFP_KERNEL);
if (!data) {
data = memdup_user(setvariable.data, setvariable.data_size);
if (IS_ERR(data)) {
kfree(name);
return -ENOMEM;
}
if (copy_from_user(data, setvariable.data, setvariable.data_size)) {
rv = -EFAULT;
goto out;
return PTR_ERR(data);
}

status = efi.set_variable(name, &vendor_guid,
Expand Down

0 comments on commit c208ed9

Please sign in to comment.