From patchwork Wed Oct 19 08:29:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp214717wrs; Wed, 19 Oct 2022 02:13:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5CMKY0QXMWjp+tRskd6cw3smcNlT3stblGZCpmTEOuC4TmD1MsSvf+QbzWPgSsYeBzhj6R X-Received: by 2002:a17:907:2d89:b0:78d:9c30:452b with SMTP id gt9-20020a1709072d8900b0078d9c30452bmr5476636ejc.533.1666170814773; Wed, 19 Oct 2022 02:13:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666170814; cv=none; d=google.com; s=arc-20160816; b=XebVUCDBmQbZmMmt+qCXdqUR5hH9wkTwyp7jLLb65VHbyQYLc6lbgMwO6fvQj65p/u PQ5ab3eUsnsVXkBeSdU14544zwnMFXCAobz4NM7Ow3jAv/pL4u/Ik9RP1W5mXgTgtQvY DyutKbr7nCC8VPX/ebyMbZ3LDQ+zVopvYSJfzcvtelvEkYhKSP6GdHA1UejxIM8WE6Bn RzEr5SxtqaJCCOVHMrW8YIHLtUZGotp9QbCe4mwLYL/UcCvoX2R7jOTA6I5FR9+kmWW3 90rRrtp88nDI+oFPbE88NnoZGUChNa6KDP2IdPXdyd5RYQa3rwnIQYkY0d1yizZrpGiB ClBQ== 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=0UOl1aiHxfbl5y0qLe8snXEwurKvOUmX+LG+chHolj0=; b=HPuAGTtV7li9qJ1QAAcsAvl/jA4Cz/OrNLz2YTd0au8Ajd5jegvphHk9FEHrY0thx0 Sng6NcTJn1rqLJ9A4Ie9HEYorygqboghnGFBGW34P/bNcxOSf7Vif3U1GjQZUyYsz7cF zQ3HsgbW2jtlTI26TX7kK4bJDi1rpqTtWfqTu9qThgtdswkwMKB8jxyDZQavZg5MIJp/ R/eleg3KZ3kD9p+FWrzxymMoY+zeAmFl8CeRywwqgIRJ80SqCA5M8qpdUYlA8YYLvTx7 lbF6gSLidNGPsHIIdpScp0aOPLvwUGHMxA+pr1NRFjUhm2wFDNlC/Elt7YqyG4BOpP5P S2Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gnoIjo+k; 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 cw11-20020a056402228b00b0043a6e796231si11532429edb.544.2022.10.19.02.13.10; Wed, 19 Oct 2022 02:13:34 -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=gnoIjo+k; 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 S232904AbiJSJMK (ORCPT + 99 others); Wed, 19 Oct 2022 05:12:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232888AbiJSJJb (ORCPT ); Wed, 19 Oct 2022 05:09:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E5CA16BCFD; Wed, 19 Oct 2022 02:00:39 -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 dfw.source.kernel.org (Postfix) with ESMTPS id A7414617E1; Wed, 19 Oct 2022 09:00:38 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BCE17C433D6; Wed, 19 Oct 2022 09:00:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666170038; bh=Wmphf3AsPlAzcTCjF/2Rty8KRXokQysKlrzKnN12nkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gnoIjo+kRQyb5ikQYUhGDccqruCZpw7Fgs8jEsk0wYIPf/a6jN6jzHvCio/pPZ11Y 66S1U5bepvCf51vYUMLZ2Oef7myuyCm1YOE0DNKxq0kEgAR7np+xW7DRQdSo7g7c2p RuQOwMgjXLiScfZZQYyd//v7B65MAvbj8miwUWSM= 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 6.0 503/862] misc: ocxl: fix possible refcount leak in afu_ioctl() Date: Wed, 19 Oct 2022 10:29:50 +0200 Message-Id: <20221019083312.212973716@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747106728022874819?= X-GMAIL-MSGID: =?utf-8?q?1747106728022874819?= 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 6777c419a8da..d46dba2df5a1 100644 --- a/drivers/misc/ocxl/file.c +++ b/drivers/misc/ocxl/file.c @@ -257,6 +257,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: