From patchwork Sat Oct 22 07:24:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7668 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1108182wrr; Sat, 22 Oct 2022 01:43:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4/yIZSrgPhBAxzV6Mk0e04OTZ5W4PFH61/1vV5U2H2XqDUMO6bmmmPO+YLZALw0MG+4S4R X-Received: by 2002:a17:907:70a:b0:750:bf91:caa3 with SMTP id xb10-20020a170907070a00b00750bf91caa3mr18723347ejb.711.1666428222906; Sat, 22 Oct 2022 01:43:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666428222; cv=none; d=google.com; s=arc-20160816; b=rKXVZjYymdqiEd2MfT7eHvckX8QK5+NZwkGcrq9tmAElHrYhZ9HTz+G0ruDqqy8ozO 8L8Ng+AYa601kTHSCdF1kBZ2zZYeD6G5PFZhG3SAo1NVsqpfVkR39oLOur0UraMP93xt wOB6crTfRTcLiMgSQWKGrx0ppMUPmONhQMtoG8gTcrm6KR4YjGLumWgtF6E22MtCMO99 g+HpGIVwOH7tL1fbjlNqwUEwkUDuVUInv2UA/QCz9KUCNK7YVu6nvi7JRYc5A2HhREhV sWLt3TUYvQ5QcZQ8mYgUkXU3bglCKezhLZDmqy4ot8aO9k48AHQSog/3WOn1X5ESZL6T DvBg== 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=yq8uTDGZJnE5YLUIXbkO1SCBR5qIhQCsH3dgPkKWu91UdYvW9Vlb05nrbIgXsjFjTw zpRNmireHQy3h6g8EUaj7AoPTtPJFnK6FA2bRLif0HkKLa3c0YWGX1LWzq9ICvxI8YHF qJ7fKFO+jELg7LC9o0CLDj7uNnCAGIG4NkhrT43UAhRBV1xTOCvnuQIbYBNk8yzabtaF K6okoBZYh/7hvLD3emSUMnxyHHeEaAlxRjVnRGVMrK2q3FVuYVXDBTLOHgsRqhLE6exh nPyAMtjwQiLQF2xvdwt0yTGtGKYlk0cCfXuWZf4C+UUM5bQsSIdlzOCU/BpSlHZGTnr7 4bKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gPW3MBKA; 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 a16-20020a170906369000b0078dbed58d26si2328759ejc.635.2022.10.22.01.43.17; Sat, 22 Oct 2022 01:43:42 -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=gPW3MBKA; 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 S234662AbiJVImG (ORCPT + 99 others); Sat, 22 Oct 2022 04:42:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234499AbiJVIiu (ORCPT ); Sat, 22 Oct 2022 04:38:50 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2A7B1A7A22; Sat, 22 Oct 2022 01:05:24 -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 A681860B6B; Sat, 22 Oct 2022 07:52:35 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7395C433D6; Sat, 22 Oct 2022 07:52:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666425155; bh=Wmphf3AsPlAzcTCjF/2Rty8KRXokQysKlrzKnN12nkM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gPW3MBKAiTTCiaR+/RAiRDK3VisNuvgnzdSOv2ehBVcHoBHm62rfUCDYFdArZhwNH vzi6/YbS6/KJC6iXwT80JhmoRaKOpm7uXwFhK0SAtRpj9wY6fveEPejdTl56xhAi9H BeTHFVXOWZgCLhTVKZ7MqoGtvlcKJiD+M4DTZstw= 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.19 409/717] misc: ocxl: fix possible refcount leak in afu_ioctl() Date: Sat, 22 Oct 2022 09:24:48 +0200 Message-Id: <20221022072516.153083178@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747376640039436801?= X-GMAIL-MSGID: =?utf-8?q?1747376640039436801?= 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: