From nobody Fri Dec 19 18:41:50 2025 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 38F0BECAAA1 for ; Mon, 24 Oct 2022 17:31:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232146AbiJXRbt (ORCPT ); Mon, 24 Oct 2022 13:31:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231984AbiJXRbY (ORCPT ); Mon, 24 Oct 2022 13:31:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 356CE4D142; Mon, 24 Oct 2022 09:07:01 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 5A97EB815B1; Mon, 24 Oct 2022 12:10:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AAFAFC433C1; Mon, 24 Oct 2022 12:10:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613435; bh=F9QdaByYRJJaL62QU8goMier2SlNAtihGwndftq3eS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xrhaMr+ZPHT84G79Mj0rrBs6lU2EK4JJGpSd7JMUItJ+LtV2csQrJaiSsxDWvJLp9 Lg+1V9IkSHyatcoW9Kd46QHz3bCoSaqf/+gYCyLblMM7RgpwEpXIa44mhnvpIKGRg2 c0B8OesKjeANqorVHMlJeNNhzhGKmRFOyY40cT3A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Frederic Barrat , Hangyu Hua , Sasha Levin Subject: [PATCH 5.4 136/255] misc: ocxl: fix possible refcount leak in afu_ioctl() Date: Mon, 24 Oct 2022 13:30:46 +0200 Message-Id: <20221024113007.102279918@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Hangyu Hua [ Upstream commit c3b69ba5114c860d730870c03ab4ee45276e5e35 ] eventfd_ctx_put need to be called to put the refcount that gotten by eventfd_ctx_fdget when ocxl_irq_set_handler fails. Fixes: 060146614643 ("ocxl: move event_fd handling to frontend") Acked-by: Frederic Barrat Signed-off-by: Hangyu Hua Link: https://lore.kernel.org/r/20220824082600.36159-1-hbh25y@gmail.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/misc/ocxl/file.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/misc/ocxl/file.c b/drivers/misc/ocxl/file.c index c742ab02ae18..e094809b54ff 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -259,6 +259,8 @@ static long afu_ioctl(struct file *file, unsigned int c= md, if (IS_ERR(ev_ctx)) return PTR_ERR(ev_ctx); rc =3D ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx); + if (rc) + eventfd_ctx_put(ev_ctx); break; =20 case OCXL_IOCTL_GET_METADATA: --=20 2.35.1