From patchwork Mon Oct 24 11:30:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9612 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp530943wru; Mon, 24 Oct 2022 09:05:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5BYxS/EIaIAP+deK8vvgAkr+QoDMJzF3bCFCty6J70SWG3HqtdDGhEsvFczuPDICjmoRBp X-Received: by 2002:a17:903:2450:b0:185:4165:be54 with SMTP id l16-20020a170903245000b001854165be54mr34308074pls.104.1666627545464; Mon, 24 Oct 2022 09:05:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666627545; cv=none; d=google.com; s=arc-20160816; b=wbDP/f9fNwnjZPqvXrAgDQCcwhLDb9ULD0IIjznGLfSJb4GqBm5x3T8HdthW/8JlBO baCuNqmnla5OTyFKWFByC8lSRIOlsBCQgVPU7zvnuJUz7w1siSjSDGdU78SsrnY4Rv3L Qfpul8EgN7rTuPI8jXTcDqa8TEFGjhNlRVNtuoEyBuD82LY8DHh5FeBL2tsJOPDayLMO ooHRpoytLYeHxXwRC51+E3mDlh3VnCJ8bORJJSU/VjEKpcrFhXPUdT9dVvgweidtW/56 Quf9dNCW2xEwfOzETW8ZKQuPoVjub5Z4WH3IpZD39LhEx+uqHvLLhxWyS6j9pB07nzgi 8EGg== 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=ce9M+lMFk8Ub4wTrcnLny+r5I5vY3ezBz9CYiu5mQWsfF/Qr7QXZsFaArzXPofKu6R m7uI0VHVFjcSRhvJKRxiZCcNmSUsOgNehBrpKWW9IXH6MQJwO/ZFB8AM5CzrybB+hMRY DC/d779ZPfbZVuDXrm2vqMu1Nkp7BGbfdoCH/qgQHyuQr79lxTwuRMIxKevCf4vPDj77 9smBq22R4kaTag1pQpmN6MN3iI0FMnvXg2Xzvz4JoUQaEFvtptEr+Wt9UptBhsHO+FjY 19zOBdzhq5n52e68GHlPbu6CyMkv42KkmPBt+gSNGcUpx/uxq/UmgwDTSs4C5FZFsRjQ cViA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=mkMnfY2w; 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 n18-20020a170902e55200b0016d9c8479b5si39691926plf.344.2022.10.24.09.05.31; Mon, 24 Oct 2022 09:05:45 -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=mkMnfY2w; 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 S230461AbiJXQDe (ORCPT + 99 others); Mon, 24 Oct 2022 12:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232373AbiJXQC2 (ORCPT ); Mon, 24 Oct 2022 12:02:28 -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 B67E315F933; Mon, 24 Oct 2022 07:55:47 -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 96387B8167C; Mon, 24 Oct 2022 12:25:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED1E4C433D6; Mon, 24 Oct 2022 12:25:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614313; bh=F9QdaByYRJJaL62QU8goMier2SlNAtihGwndftq3eS0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mkMnfY2wEGj4nk8/WwD1l20F56HH+OWioR7LB1H2ksFiza8axrthcX6ls6tGVeLzA nOCuXB/aklNf7rIcepKavoNdiVaW0XaS75xdqGukmy1dMFEx401NEIp+MwQKjeQv6Q 2XevV8OOvuZ5k7+Jrkeev90rF438eF6BJzNI742U= 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.10 212/390] misc: ocxl: fix possible refcount leak in afu_ioctl() Date: Mon, 24 Oct 2022 13:30:09 +0200 Message-Id: <20221024113031.820902760@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747585644924345648?= X-GMAIL-MSGID: =?utf-8?q?1747585644924345648?= 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: