Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9209065pxu; Mon, 28 Dec 2020 09:19:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJzDwmGr0avPN9lz/fwc3lmsy6Qw4fqbdCyZi5ACpWlg485h9ggZVH9FgO64hAgevNP2PbfY X-Received: by 2002:a50:cdc8:: with SMTP id h8mr43659909edj.293.1609175964403; Mon, 28 Dec 2020 09:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609175964; cv=none; d=google.com; s=arc-20160816; b=ZOKXfHImaj6tUwvsixzgq/+tcWxdMII8j6lyRMBNhNGliZB4pW53x2uqf42+lpt5Bt qPyRcDcb4RY0sJ5zjMZ2xDEiECs5UO47QAFibSRBVOaL0dHPE2KZxCKBBNqcfUAX6DlR TVNB53o3e2vRZb1Rgfc5Yl10pzWmJBRmR+Pd/ZjNBognjzH/EK26ZHQIhCr8yM2Olosb Mup1wm8qJDoWOTLK3813Rlqavs6+/kyrbRcL8NQPZ54pg8hnJc1ohayVfpDp3IK1svf1 GENtVshRxjkNRx0VcD1BZN7v2DE3+a+QSDLdTWO84FdLvg+MxqC1WTwjslHixWRSdJP6 fq9g== 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=c5Q9BCkNHBeMl/a1sJES69xy2yld+qjVCEAwwdBgY/g=; b=SBzH9PScnjQYrgLH9q1knwzJTaqc97CmdkUh9Nh+r/SxAxQ101naAb4DTNlAmB5GZK BKsv7R9rqGhbQfX1Igy3Zc41NUqXAf88wOZYAL0sjZhlLVs6z6WLyc/qfvJnm6nRWja5 oB2EkMu0XFLF7d8SCGNYjUtKsWvui6DiSz0julEFLSqYi92E/lfU/nXWA/YX/39VvBvo 8jyvpXmCd4p/I5ct78FTUurzgvPD7YJornMyheOKG8SHSXImtMDS6vJfUqyZrMxRiRHU 50tj5cR7/51BSrdaAkWwCuuhyx+pHJmKMYNoMCh2NurAJl5ZnJODws4Liez8/pJaBkKe bZxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1mhr4tf9; 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 hp39si18940680ejc.214.2020.12.28.09.19.02; Mon, 28 Dec 2020 09:19:24 -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=1mhr4tf9; 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 S1727988AbgL1M4a (ORCPT + 99 others); Mon, 28 Dec 2020 07:56:30 -0500 Received: from mail.kernel.org ([198.145.29.99]:52904 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727880AbgL1M40 (ORCPT ); Mon, 28 Dec 2020 07:56:26 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id A6281208BA; Mon, 28 Dec 2020 12:55:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160146; bh=ZfmRCxWQg9s5e913kMLw80E0+cqobIeZiMmy9oWO2vo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1mhr4tf9njIRVBXVIHV70q61ZjdEdxeYnKu77oPMwDtusUPluLz4l/0ab1YZJDYR3 6wz2HKjOZijdUcn7QAcBNnncFin0oY3RPo6JbABbSItrZBl06VekOk/XcTa2LO/H0l OedOWJNRGMU+02hO0TuCh8YdiKl7UZ2jtm1iVpIA= 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.4 084/132] nfc: s3fwrn5: Release the nfc firmware Date: Mon, 28 Dec 2020 13:49:28 +0100 Message-Id: <20201228124850.495097740@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124846.409999325@linuxfoundation.org> References: <20201228124846.409999325@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 64a90252c57f2..b387845d3c72a 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