Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9395686pxu; Mon, 28 Dec 2020 15:06:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJzD0ina2WJkUP2pJVlJeIOSYDUZsHo/h/XHOVmhmIF4P/wQqyQ26QqfMVTCBMl+xBl4wvWf X-Received: by 2002:a17:907:3e85:: with SMTP id hs5mr44542451ejc.548.1609196799818; Mon, 28 Dec 2020 15:06:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609196799; cv=none; d=google.com; s=arc-20160816; b=TvXVBaUc3QVHdtLjn1L1Ad6r6MJJ2eOpIB5qxSCXvQodcT3LhM5HWDIvM9oMd0sUtd OaqamzsleKzwqmxMKsZSOnKdulsKc7cccNXsguYNKsCfA3voeUlqW+mOVuvhLMh90jxA YBxQdXGHCC7FeMeqv6jK+RMtzo0qiWkblIdbM7onqCgcMp2+Mbw75R8xYsfasXXE1nOT wghGBRhTTAWDiodSca1ad3sAZgXtjs6zvxWlH2eWkao8o65QPuKG2v5C0ZAHydLpLkCk ZMOUkuVI31knzNE1H3kcytDtlNO+3g3ruEPcorR8JNMoQIFWVjQ0RHIXUDb7Nad7PHpn cmBw== 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=7RwJZB1ftIZZ3i4QqHRk9agOWTnhH402PFuGl1W2Q+U=; b=RHTCL8SpfvPUdzRI4EnWFn6nqvdacd1KIcksgPbANqQsb1APQ2X6DpBG/Bo5F1ZHXg B++lcW2c3f7v7BU/ZNJ/cCi8pfK8kaPUL052GChXQ3itRrZdc6d3IZOQd/+C0+WTtD0r gaTlKkxSyOTy9XO95TGYflP8Kb7fnuGADYaIvH3fAjj6p0UKa8XojfUindDkNjouur1/ N2sg9955i+I0YJEcC3jVaepPZs4pA8UxhFBYrs8hHpd2ARzd95njzNwEE1E15F42xxSh LqvS4kIqFWW1i1XQrhF/kW867B4GVDOjduiEUA+q3bz8lo9u1AbUKMFNfferfxHKEF+r yT2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kOYje4hl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ck10si21029222edb.568.2020.12.28.15.06.18; Mon, 28 Dec 2020 15:06:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=kOYje4hl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S2438235AbgL1OGu (ORCPT + 99 others); Mon, 28 Dec 2020 09:06:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:40856 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437873AbgL1OGO (ORCPT ); Mon, 28 Dec 2020 09:06:14 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 21E2B207B6; Mon, 28 Dec 2020 14:05:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164333; bh=TEdnqWdjjDu9DHd2eze2o2SrxM0uyzuNi3qi3D26uHk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kOYje4hlQqAGcEhFYuzyoLbGnufCXYM20MXRSkhDbH2VJeeNd58OMno6wwkX/sfBd qolS3ASo6tQqdcHxSg5UIPKHeYmzhclPqypE9mjkkBzjHIVFJv2BiRSpyfCGDtDLkS JUC6Lc3izLvLyKZEo8lAdSO1STrLvX3DCN2q/lAM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jing Xiangfeng , Sasha Levin Subject: [PATCH 5.10 112/717] staging: gasket: interrupt: fix the missed eventfd_ctx_put() in gasket_interrupt.c Date: Mon, 28 Dec 2020 13:41:50 +0100 Message-Id: <20201228125026.324107976@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jing Xiangfeng [ Upstream commit ab5b769a23af12a675b9f3d7dd529250c527f5ac ] gasket_interrupt_set_eventfd() misses to call eventfd_ctx_put() in an error path. We check interrupt is valid before calling eventfd_ctx_fdget() to fix it. There is the same issue in gasket_interrupt_clear_eventfd(), Add the missed function call to fix it. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Jing Xiangfeng Link: https://lore.kernel.org/r/20201112064924.99680-1-jingxiangfeng@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/gasket/gasket_interrupt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/staging/gasket/gasket_interrupt.c b/drivers/staging/gasket/gasket_interrupt.c index 2d6195f7300e9..864342acfd86e 100644 --- a/drivers/staging/gasket/gasket_interrupt.c +++ b/drivers/staging/gasket/gasket_interrupt.c @@ -487,14 +487,16 @@ int gasket_interrupt_system_status(struct gasket_dev *gasket_dev) int gasket_interrupt_set_eventfd(struct gasket_interrupt_data *interrupt_data, int interrupt, int event_fd) { - struct eventfd_ctx *ctx = eventfd_ctx_fdget(event_fd); - - if (IS_ERR(ctx)) - return PTR_ERR(ctx); + struct eventfd_ctx *ctx; if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; + ctx = eventfd_ctx_fdget(event_fd); + + if (IS_ERR(ctx)) + return PTR_ERR(ctx); + interrupt_data->eventfd_ctxs[interrupt] = ctx; return 0; } @@ -505,6 +507,9 @@ int gasket_interrupt_clear_eventfd(struct gasket_interrupt_data *interrupt_data, if (interrupt < 0 || interrupt >= interrupt_data->num_interrupts) return -EINVAL; - interrupt_data->eventfd_ctxs[interrupt] = NULL; + if (interrupt_data->eventfd_ctxs[interrupt]) { + eventfd_ctx_put(interrupt_data->eventfd_ctxs[interrupt]); + interrupt_data->eventfd_ctxs[interrupt] = NULL; + } return 0; } -- 2.27.0