From patchwork Mon Mar 6 21:26:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fedor Pchelkin X-Patchwork-Id: 13162357 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46FCC61DA4 for ; Mon, 6 Mar 2023 21:27:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229787AbjCFV1I (ORCPT ); Mon, 6 Mar 2023 16:27:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229627AbjCFV1H (ORCPT ); Mon, 6 Mar 2023 16:27:07 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1277515C3; Mon, 6 Mar 2023 13:27:06 -0800 (PST) Received: from fpc.intra.ispras.ru (unknown [10.10.165.10]) by mail.ispras.ru (Postfix) with ESMTPSA id E7EF140737DF; Mon, 6 Mar 2023 21:27:04 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru E7EF140737DF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1678138025; bh=MMdH886uaIHU3k4OniEz5qYWbc40cmBeDwnXZ2fjIog=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hefXv1iI6P/RmXzKFsjbtTWhmxWS73VDhDcgiT6Y3wKwe4MGIgVsEE4fT6hm6H5Uc nyaW0ApA8EMAfnj6lI74tnVROrwJpjZbnky2qRccmwvinF1Fcp+m1IWjrzs5rfwiPK +NdBmSPjjDgj97fajujuhdETd1XronfIdc7NHFgA= From: Fedor Pchelkin To: Jakub Kicinski Cc: Fedor Pchelkin , Krzysztof Kozlowski , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH v2] nfc: change order inside nfc_se_io error path Date: Tue, 7 Mar 2023 00:26:50 +0300 Message-Id: <20230306212650.230322-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230306125842.7fea0be5@kernel.org> References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org 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 --- v1->v2: remove 'no functional changes' statement from commit info net/nfc/netlink.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/nfc/netlink.c b/net/nfc/netlink.c index 348bf561bc9f..b9264e730fd9 100644 --- a/net/nfc/netlink.c +++ b/net/nfc/netlink.c @@ -1446,8 +1446,8 @@ static int nfc_se_io(struct nfc_dev *dev, u32 se_idx, return rc; error: - kfree(cb_context); device_unlock(&dev->dev); + kfree(cb_context); return rc; }