Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9038219pxu; Mon, 28 Dec 2020 05:07:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJyWzmtDfucHugskJ+SmeIN9Aa8DDlaGhhinAhNFAHSmxNyQTcRpoeqZb+vcJ/0ghgtGJcm0 X-Received: by 2002:a17:906:9452:: with SMTP id z18mr42101289ejx.389.1609160840426; Mon, 28 Dec 2020 05:07:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609160840; cv=none; d=google.com; s=arc-20160816; b=CAm/2c1WH8kkTtxURnsuW2qXe/+Yw98ZTzeiwRGCbsQDKAwR5UnSfK89ten+1sbQ1p nNhpU8U5TY3XzzuARpKpoOLVRKt/4DDLyuyLM6ZPrEMA3d7qUwfu06eVOXwDfOMqME5r DP0XR52wdSM9mHDvMYrN+MuWWavFv5TVASWykakVznmbyCSlraDqpP6E2xg3TdKow4rR hgY5S9mAnZrpDYvkO5TRsdIJV2wUK4Rf592hJFrjkl2DdUcONyxCeH3+JW6uBzSDbhgV gNT1+j3qzPeCkNQFR3/JuKYvLqpvan1Gqgq9SPTjlhnj5z5Fqnf5dP1ihEiCZlY7+ewl E4jQ== 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=z4vycCM6eVrCoeIdN0DafBS632Zz0Ttd7jbhc30cHM0=; b=ZnKCGApVaaDiEFWBpDOutfW37DP3FvVYklwSn5HGwBXLOz6egnTpFWj1YEVcMEMwvA TNAyksOoVTYXDrNuADYbDU2g++Af1b3a+i4P8rvldrRdp9K4fHPV/B09ueIFVAxz1A1n WgzZELL3x0TY3Q7sceIyXYYTgk/rr8M6ZcTcCopjQ8s13MRgOhtU36KsSqkpS8UpNzV6 h601XhZk1h48KvnY6esV96NJSpfYJyoQRrubK95mSjTtAGNzqwmm3FTZkJeZX8mjPx7g 0qZE87Zm4k8Km4l/zPk6OGobYymtKpOFtiGG9RiuVHnvlnNwnEC6xRAXhVF0J6L/ifvY FykA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p6cqLgMD; 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 nw24si18875908ejb.647.2020.12.28.05.06.57; Mon, 28 Dec 2020 05:07:20 -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=p6cqLgMD; 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 S1730527AbgL1NEy (ORCPT + 99 others); Mon, 28 Dec 2020 08:04:54 -0500 Received: from mail.kernel.org ([198.145.29.99]:60762 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730474AbgL1NEg (ORCPT ); Mon, 28 Dec 2020 08:04:36 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7AAB521D94; Mon, 28 Dec 2020 13:03:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609160636; bh=aHniJjZWYDqJ8uI0brVmuB9pz9xGHCTqUR9DUqDyVkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p6cqLgMDIwaAKsc2+FjvcsZouv1Vub5JMC7TwzSxEGqePlrOzofj0rvKLEDGe3ggW m9XXvDMyxKPQS5myvcnEmDqGDQ9yBwHJ7wI7fRqeKil8eNIpsEykXGrdN/Nv9NdFJS /7AY0S6FYz7S0H0AXP0rR/m3hD1NDQzQ1jbjS51U= 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.9 117/175] nfc: s3fwrn5: Release the nfc firmware Date: Mon, 28 Dec 2020 13:49:30 +0100 Message-Id: <20201228124858.924140659@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228124853.216621466@linuxfoundation.org> References: <20201228124853.216621466@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 5f97da1947e39..e6ca1f9a7f63e 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