Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9228220pxu; Mon, 28 Dec 2020 09:52:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHMGH016X8DrbjsOR12A/ICKw7iUfSMtorqd94mttoGJV5E0ttAImyA9wd0z+9je+X/qAp X-Received: by 2002:a17:906:c45a:: with SMTP id ck26mr42908750ejb.200.1609177931493; Mon, 28 Dec 2020 09:52:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609177931; cv=none; d=google.com; s=arc-20160816; b=XMMK6TNDpoun215TqRop54YAEKTiqfgSCdVb6GoO4tBEQOupCfJbjWw1l/Xp0yTcDg RODvV85Z3cK0yw4PHXmMc+UXiATqBX0aW9dn5Lu93/YgOLrrjidBr3JbS7heIOjsUa7A vuNpCoQ0K5brpgNGfte5xUsYMCmRCeqi6mnSE/v1g06Nht0QWCHExGEAMrkX6wrJPpim xxczHg5WKzIw6OHRclkBfSzb9LbAyVAhh+UtVD/jPkE1eQpQYdweq+nbtL21BR3ZrNT3 Wq+7x8kE8qFoPTtWc2+0JgsvFSPfWjNbVr5RE4i3hUP90g0FQj6izI3/t4pgUlRPL5Pq JzIA== 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=b/iwANP6KHaKeXRcNz1lxdIsLQnNnJboJe4tD1j4RX0=; b=vURLXwCaDYN/hB4eOY7SpepJjH3IAPqxW6fJuC39aVpTOSaaKIJl7ZN1SuXgkBDvcC 4f91zjKvoCquMJm47Wi2ELkaVzq2SXe3dEeXRh0XdhpdNR3xGlheZlt7BCincazfyehB k79op/DvC/fLR8LEOCihKC1NYqYxwZRm+AlAE1V3Ib8kljQhsydJWbC4BLaXlDC/9I+j gqFnJDNLbBeSA8zao+33IwvJlrqQtpT+ty7hoqXIxEIgkSzYProvegViljZ+FIgY4reF ZEsNy6vsZY7LucSUyQOFKcGacqnt2QTP5m2bF6hpGRGnXD7AosmXbNsqO7zSje0Yx0Vw 5kPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=hYS4+f0L; 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 i8si20688260edr.271.2020.12.28.09.51.49; Mon, 28 Dec 2020 09:52:11 -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=hYS4+f0L; 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 S1732678AbgL1NPY (ORCPT + 99 others); Mon, 28 Dec 2020 08:15:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:43604 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732666AbgL1NPV (ORCPT ); Mon, 28 Dec 2020 08:15:21 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 75DE520776; Mon, 28 Dec 2020 13:14:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609161281; bh=kt6fd5ZHyxMl98NgNZT9NDo+I3LbalJ9YuzuyURL3Mc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hYS4+f0L4fb73Kj0ZPeFNSF1LAMFJmnpzowBqXeUY+vbdyDoSDQUxDP1TiiEZff22 59HZit86cnceRz7UELfulK5PxFo7lmqW4ZIy1u/0f+K6gshv7koGxCKPmLKI++GjV4 0IrHf8fAZXlnI5wIBwcSglcGEjybNKvFIHXy8VAY= 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 4.14 162/242] nfc: s3fwrn5: Release the nfc firmware Date: Mon, 28 Dec 2020 13:49:27 +0100 Message-Id: <20201228124912.673657605@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124904.654293249@linuxfoundation.org> References: <20201228124904.654293249@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 38548bd970cd2..43c801e725b6f 100644 --- a/drivers/nfc/s3fwrn5/firmware.c +++ b/drivers/nfc/s3fwrn5/firmware.c @@ -304,8 +304,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