From patchwork Mon Oct 24 11:30:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9888 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp571603wru; Mon, 24 Oct 2022 10:33:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4jDUmgxbk/s4tc7sXXqtlyayNs8KIhTS1XdheYPV/F6H/bBw1wALUaCY4LgzvvFRc5BNGT X-Received: by 2002:a17:902:bb98:b0:186:988d:a0f0 with SMTP id m24-20020a170902bb9800b00186988da0f0mr10403698pls.10.1666632809470; Mon, 24 Oct 2022 10:33:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666632809; cv=none; d=google.com; s=arc-20160816; b=m9b0pZb3bYzT4hHKyQ11QlLFPpKKAb4/HgSs1IOiFU1v3BlP7IYwwcbNORsiyC2BoS 5eGuS2q3h70jdd7GVxwIhStySRAf0myUE5BqC83XgrrkHA8NwLEkV94CxY6INwINR9r5 uulv6agOgEUosYfARPfhmVqh+jRCvr9SSOntNVtUCvVp9ZKBvMwuZOHp+B0GBjRiYjEw I0USQcliCh4sxCQAvnG1Hx0l/VXpG80iMz9tsQo93FiOmBtOlvNc0+My/C4APdszbz9K 9CuR/5J+0okaLg9KSASeOoTYmONqA+7uoIgkbZKux3+jBhUbYUTfdgSow9BusVNMA8yR aeLw== 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=tiZMvgom47ZskvD9/GGQoI+2kuQxUSJ+bjsHRgYACvo=; b=EmjphtGfnetV2s/HXnj2B8uiPSRvcoNT2Ia7t9wf+NZU0wOQB/GRQHn3bTW6V+mZvD r7lw36+M52HgcU+nCzpSuXj6qDxPkDjI18JsabGz9/fwr/xxYwlE+p5hbhgORMQeZ96I Bco3zung/PkiuUqhiv8nT3Vc5xojZSqa7c1amXn84SY5+AtOMvZMgElUtJLbXCVgNGgy mWPVD+RK834bnvEMCNW8orVggotW2R4qiUpdYuUeA0QhvQukCkaAsXy+bovyQY0ljwfP F5Y/DClXsvM8AM5l8075LXC74hU1/VjCsI+YewTzz310+71PBGzKe0G3nKjQ2INz9rFZ eZ0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xrhaMr+Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z37-20020a630a65000000b0046eb1d42b66si100179pgk.284.2022.10.24.10.33.16; Mon, 24 Oct 2022 10:33:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xrhaMr+Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S231726AbiJXRbr (ORCPT + 99 others); Mon, 24 Oct 2022 13:31:47 -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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747591164588039997?= X-GMAIL-MSGID: =?utf-8?q?1747591164588039997?= 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 cmd, if (IS_ERR(ev_ctx)) return PTR_ERR(ev_ctx); rc = ocxl_irq_set_handler(ctx, irq_id, irq_handler, irq_free, ev_ctx); + if (rc) + eventfd_ctx_put(ev_ctx); break; case OCXL_IOCTL_GET_METADATA: