From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5932B4431 for ; Wed, 15 Mar 2023 12:14:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D4577C4339B; Wed, 15 Mar 2023 12:14:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1678882496; bh=2+1XVPTwUsBuvgi3xyK63RMGcqbgFx5/B5npAGAu4vs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IHUdFV+Hqky43wbt/zi9+OQxXTVnEYM7Q0Xh/WCDWzJWcPX51dJBbFizKyrnG50Pq 1wumF+c6FnBtbvgE1+oktzNzT+dp04E4Li+Iy5wo5/+nx7yHy18cp38dz4ICBvjcg/ gxfMxvYNzCBUCmmy0r6DnLwDM4tGnbY5j5N81Lbg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Krzysztof Kozlowski , Fedor Pchelkin , Jakub Kicinski Subject: [PATCH 4.14 08/21] nfc: change order inside nfc_se_io error path Date: Wed, 15 Mar 2023 13:12:31 +0100 Message-Id: <20230315115719.137693801@linuxfoundation.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230315115718.796692048@linuxfoundation.org> References: <20230315115718.796692048@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Fedor Pchelkin commit 7d834b4d1ab66c48e8c0810fdeadaabb80fa2c81 upstream. cb_context should be freed on the error path in nfc_se_io as stated by commit 25ff6f8a5a3b ("nfc: fix memory leak of se_io context in nfc_genl_se_io"). Make the error path in nfc_se_io unwind everything in reverse order, i.e. free the cb_context after unlocking the device. Suggested-by: Krzysztof Kozlowski Signed-off-by: Fedor Pchelkin Reviewed-by: Krzysztof Kozlowski Link: https://lore.kernel.org/r/20230306212650.230322-1-pchelkin@ispras.ru Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- net/nfc/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1454,8 +1454,8 @@ static int nfc_se_io(struct nfc_dev *dev return rc; error: - kfree(cb_context); device_unlock(&dev->dev); + kfree(cb_context); return rc; }