Skip to content

Commit

Permalink
nfc: s3fwrn5: Release the nfc firmware
Browse files Browse the repository at this point in the history
add the code to release the nfc firmware when the firmware image size is
wrong.

Fixes: c04c674 ("nfc: s3fwrn5: Add driver for Samsung S3FWRN5 NFC Chip")
Signed-off-by: Bongsu Jeon <bongsu.jeon@samsung.com>
Reviewed-by: Krzysztof Kozlowski <krzk@kernel.org>
Link: https://lore.kernel.org/r/20201213095850.28169-1-bongsu.jeon@samsung.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Bongsu Jeon authored and kuba-moo committed Dec 15, 2020
1 parent 8163962 commit a4485ba
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/nfc/s3fwrn5/firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ int s3fwrn5_fw_request_firmware(struct s3fwrn5_fw_info *fw_info)
if (ret < 0)
return ret;

if (fw->fw->size < S3FWRN5_FW_IMAGE_HEADER_SIZE)
if (fw->fw->size < S3FWRN5_FW_IMAGE_HEADER_SIZE) {
release_firmware(fw->fw);
return -EINVAL;
}

memcpy(fw->date, fw->fw->data + 0x00, 12);
fw->date[12] = '\0';
Expand Down

0 comments on commit a4485ba

Please sign in to comment.