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 1B1B4C64EC4 for ; Sat, 4 Mar 2023 16:49:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229568AbjCDQtO (ORCPT ); Sat, 4 Mar 2023 11:49:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229455AbjCDQtL (ORCPT ); Sat, 4 Mar 2023 11:49:11 -0500 Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 787181A676; Sat, 4 Mar 2023 08:49:10 -0800 (PST) Received: from fpc.. (unknown [46.242.14.200]) by mail.ispras.ru (Postfix) with ESMTPSA id B9C9244C1023; Sat, 4 Mar 2023 16:49:08 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru B9C9244C1023 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ispras.ru; s=default; t=1677948548; bh=vA0uddaAF4XkgrzjTMknhDOe+mBtUEC4F4gPVaK/S0k=; h=From:To:Cc:Subject:Date:From; b=gv57uY8XyHCNo2SNdxOBtVjHHinjaG8id0LpuoJRefFLuKBHZxZ5V+KMUqHqOpaE/ WKTtB6v/1LYnxpg02YirFjw8uQd5dj+C77e0ztCX9yDUNwVoyWaHzeQBN4Dj8be5qv klwglD/CjpjonTWWs1TQB6u43XGUofPGnr/AQb5g= From: Fedor Pchelkin To: Krzysztof Kozlowski , Jakub Kicinski Cc: Fedor Pchelkin , "David S. Miller" , Eric Dumazet , Paolo Abeni , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Alexey Khoroshilov , lvc-project@linuxtesting.org Subject: [PATCH] nfc: change order inside nfc_se_io error path Date: Sat, 4 Mar 2023 19:48:44 +0300 Message-Id: <20230304164844.133931-1-pchelkin@ispras.ru> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org cb_context should be freed on error paths 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. No functional changes intended - only adjusting to good coding practice. Suggested-by: Krzysztof Kozlowski Signed-off-by: Fedor Pchelkin --- 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; } -- 2.34.1