firmware: Google VPD: Fix memory allocation error handling
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Fri, 5 May 2017 19:08:44 +0000 (21:08 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 May 2017 15:01:46 +0000 (17:01 +0200)
commitf6375f3cd40e5a604268a9c86b3be1581c66af3e
tree144ae9078e32df6662652778621ae439c3677ad0
parent0e5bcf13e81d06ee48169aafe6a2a63fb6e710aa
firmware: Google VPD: Fix memory allocation error handling

This patch fixes several issues:
   - if the 1st 'kzalloc' fails, we dereference a NULL pointer
   - if the 2nd 'kzalloc' fails, there is a memory leak
   - if 'sysfs_create_bin_file' fails there is also a memory leak

Fix it by adding a test after the first memory allocation and some error
handling paths to correctly free memory if needed.

Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/firmware/google/vpd.c