Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9090900pxu; Mon, 28 Dec 2020 06:24:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOvhf5NfidvZ7qjwAf4wt7EOKVcfLez+CHvZLwQdHHUwmURTHoTXdIPVWJ71WylYOdQWzn X-Received: by 2002:a17:906:7e0b:: with SMTP id e11mr40960272ejr.533.1609165495496; Mon, 28 Dec 2020 06:24:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609165495; cv=none; d=google.com; s=arc-20160816; b=ojo6Dq/R2IlAa17lfkYbnT3T7hXgEwVpxC/FHn/NdpXSdCf4epMvyZ1hFFqWzL9tm5 QA/gCCcZ8kwPzAxUJBEEd+n0Bougs9PORcoNIBdx2fgkUxfBUQXmtWUsPSzpCXibQWkQ 0zj5SGHV+2o3RjVwkmaageCXbKWu9oLzwwFBtN2bf8ke9ckMlQG74z3nCtmmW0lu0742 5wrRxT009dH6B7LIuknADqdPOEJ3feqtP4yHwKdHE8ybgbzRLHC2iuBy8tENdfrJZy/1 DMZldJt1kGZ6rh7W3zcLKzrjPa3XlJC30Eu0ukL818FxYqXLKdNmBvpKtQy+h9h7htHZ r2+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sp8nCJ5TwpjA4HeIIBdjnIsIet9hfae584wCptK9r10=; b=nJiMQvy8IJHK2nOD3m0MkeW04V70sq0JCSYVed/8YdicswdCZC1LcqNYe4/Ad3Xi2j qi661HlTvKhw/+9t3IEfMhG3eYzA+blagW4kAOE+EVezNJ6ocw1pL8VaslMqW1Lwre5B a7P+hCOZrY/NIZRzo2kN0mClpyy7Kv5cIAQDD53JcoHs5hsWHazdSMw6QVPQaBT3oIIR SIH+6V31ZYyJZhMYJFm1lg6/cyqpWrQIOhNwt1H5XaTzwqYqqy9GQhgX1adCTpbZDFmQ es76Q6elUX4rqsMCqkm3YV4Kg8r/wHwKNJSHJ3ivZzAC9jQD0ncTeVLvH37JXgAr0xoY jcLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A61hhtJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e23si18025296ejd.730.2020.12.28.06.24.32; Mon, 28 Dec 2020 06:24:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=A61hhtJa; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437802AbgL1OUj (ORCPT + 99 others); Mon, 28 Dec 2020 09:20:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:55760 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437791AbgL1OU3 (ORCPT ); Mon, 28 Dec 2020 09:20:29 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id D2352207B2; Mon, 28 Dec 2020 14:19:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609165183; bh=wftp2cSyFblKaOqhH7s9VkrcaGRhdM/JI5UaMkd+yTM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A61hhtJatjUozv+sa7t77m4l9QV5TVy7drTRdmzQUS31oBrNmBGGavynF5dhA/CEQ zW9xOyaDDkd4R4Vj2I2gupfqYo4gAuy/ot/yVJxHB5Z5EeHk4cLUk9llu5qYg5aozC bxMeYIZETrqTT/rwqtwbD1Dl2g8jAFssZQnUOwfs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bongsu Jeon , Krzysztof Kozlowski , Jakub Kicinski , Sasha Levin Subject: [PATCH 5.10 440/717] nfc: s3fwrn5: Release the nfc firmware Date: Mon, 28 Dec 2020 13:47:18 +0100 Message-Id: <20201228125042.049326129@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bongsu Jeon [ Upstream commit a4485baefa1efa596702ebffd5a9c760d42b14b5 ] add the code to release the nfc firmware when the firmware image size is wrong. Fixes: c04c674fadeb ("nfc: s3fwrn5: Add driver for Samsung S3FWRN5 NFC Chip") Signed-off-by: Bongsu Jeon Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20201213095850.28169-1-bongsu.jeon@samsung.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/nfc/s3fwrn5/firmware.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/nfc/s3fwrn5/firmware.c b/drivers/nfc/s3fwrn5/firmware.c index ec930ee2c847e..64df50827642b 100644 --- a/drivers/nfc/s3fwrn5/firmware.c +++ b/drivers/nfc/s3fwrn5/firmware.c @@ -293,8 +293,10 @@ static 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'; -- 2.27.0