Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp4975614rwb; Wed, 21 Sep 2022 01:04:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AFa68LimUk+Q33L2EORvEf2roCwcrOy59GX6bI9Bu5lqMEzKsca7Kwh5LVau1VdsYYacV X-Received: by 2002:a17:90b:38c6:b0:203:3dfd:6fcc with SMTP id nn6-20020a17090b38c600b002033dfd6fccmr7950949pjb.96.1663747454706; Wed, 21 Sep 2022 01:04:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663747454; cv=none; d=google.com; s=arc-20160816; b=SYKencnI4qbFmksKWzg1hofZBtsBBCq8bRqaSKsd+kfXtEdqM840GYBKwOEFcC1cQn /cT4lAoeDMgvmYwG03W1+Ty5FsYmG5Fpz4D7tlPXmBBue/x50mYxihQX09Bey6KrQFBw G9Oqye8ALECP/uqB9RP+gK+XJROV1kC/szDUY+5QBF7sbOnEuQisaFs+IOi+mBZ0wveG nhSnGlMsT+Ek+E8ZARIhk4ABIne6BRPAx8Mt+WokJe1yL3sIxYA1xXFVcuqcy4GoCdc7 GBifzOlIKc6JpU1futRT56+xrpIA3r/gfGp5aoNulHEhGtSO5tG00BKMK16ZZfv6uDcL hsMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=rTQHRpCuYWTF0TW7ZqPRytz1miu1sr94XDRZMIsgnL4=; b=MYQtDO06bD5mHii/Pl5eJeyNuaM3uc7BztA6k3rGj3b5iwoCRnL1OCaz8R6O6pAP/B KxNTmeSVBrZdYglpbxbKq43hmJRbKZIw3mH9+touRpPLe+CPWy2+H8+UVQOv1v3h8xtW /x4BfeOGDaUILpCaumKV3dZBUSbGwRl4V3r7hxSPtIJSletf8ENIDJ8h//mesQyHHiEH AG8otayBvWr9vJCxVVPKCG4fXBz6aCJKNwMjv0Uot6/4suas6wRnYIhgx2ZRnEAlt1+7 2avBa/VXHdv0p3NKMZ/YuZj1horKke9Ev7yUKVTSdA/S/Q5HWFI2KtUhA+EW/wG/9iw9 jfGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=SoG1y4ff; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c11-20020a170902d48b00b001733a212ccfsi2112457plg.330.2022.09.21.01.04.02; Wed, 21 Sep 2022 01:04:14 -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=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=SoG1y4ff; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230110AbiIUHdT (ORCPT + 99 others); Wed, 21 Sep 2022 03:33:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229521AbiIUHdR (ORCPT ); Wed, 21 Sep 2022 03:33:17 -0400 Received: from mail-ed1-x52e.google.com (mail-ed1-x52e.google.com [IPv6:2a00:1450:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D55DB8305F for ; Wed, 21 Sep 2022 00:33:15 -0700 (PDT) Received: by mail-ed1-x52e.google.com with SMTP id z13so7262201edb.13 for ; Wed, 21 Sep 2022 00:33:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date; bh=rTQHRpCuYWTF0TW7ZqPRytz1miu1sr94XDRZMIsgnL4=; b=SoG1y4ffqJysqfAETOiLczIeeg0p+5834Zi5KDxCo+qQTGQhPSdFKfVGTOogBy8ymo 97xDbl+VLIxe5GtnP560IpvbcKvVxU+PW/d3pqbY6pLFu97p64yn4ieKfQgVE35YluP3 Ks4sQBv5pm3TvaL4j+f4Bzhcjhkxwy48AETBioAgFRWXcvSfJer8F+t6HcS1JtCMlemQ McDv+5IaGlJBQw1GPGlrbYBiNl+/1HN4bVIluYsLGo0xKouVnsNRzFTCJaiV/mEZgdYn TfE1zZUxmGMSmH0bXwWBeDncqufpR5fBA5unv2uS8CjaLceXGWE6+ojI3um07JxSHtxV UStA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date; bh=rTQHRpCuYWTF0TW7ZqPRytz1miu1sr94XDRZMIsgnL4=; b=AasPEtCsYZ2ADoNozVeUpGRk3sJgfyaF31khoqrdX50ScA3VJTNegSNiqDB8pMUF7t I8HhJKGIDc2hj3oGrqamouv58AKVJKsntjPyEntDHMU5WngSmzhLTf5Cdgv2Mu/2OqGL a8ROW/z1M6QNWdW8PWpHnXYUHF0rGf4RIG9ZzVcmyrbIl+6WvjSxK6zGD0faCsXQWMgM MbF8Pab1/+nFX/83FDDB0QUQwUravX/o4obVH9UnDDtL7vLbmntfTNBpvDZGqqzwQwUz 7LjJKEYPPSZJYzoh6UBtWK7XUCUkjFBtZkxqWRQmrsqSbaGtrmsrlSfourtihUed1lGF fU+Q== X-Gm-Message-State: ACrzQf17UVfymzi45T60SsQl+Jx2Y5WPdAqVAfBQ344m040LbJvyFr7J XMcP3HTnsmVTofbn5ExNbsCuNhVMea2ZGesXMah5Kw== X-Received: by 2002:aa7:d488:0:b0:454:646a:4f98 with SMTP id b8-20020aa7d488000000b00454646a4f98mr7041993edr.408.1663745594398; Wed, 21 Sep 2022 00:33:14 -0700 (PDT) MIME-Version: 1.0 References: <20220921032020.25398-1-Meng.Li@windriver.com> In-Reply-To: <20220921032020.25398-1-Meng.Li@windriver.com> From: Bartosz Golaszewski Date: Wed, 21 Sep 2022 09:33:03 +0200 Message-ID: Subject: Re: [PATCH] gpiolib: cdev: Set lineevent_state::irq after IRQ register successfully To: Meng Li Cc: linus.walleij@linaro.org, warthog618@gmail.com, linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE 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 On Wed, Sep 21, 2022 at 5:23 AM Meng Li wrote: > > When running gpio test on nxp-ls1028 platform with below command > gpiomon --num-events=3 --rising-edge gpiochip1 25 > There will be a warning trace as below: > Call trace: > free_irq+0x204/0x360 > lineevent_free+0x64/0x70 > gpio_ioctl+0x598/0x6a0 > __arm64_sys_ioctl+0xb4/0x100 > invoke_syscall+0x5c/0x130 > ...... > el0t_64_sync+0x1a0/0x1a4 > The reason of this issue is that calling request_threaded_irq() > function failed, and then lineevent_free() is invoked to release > the resource. Since the lineevent_state::irq was already set, so > the subsequent invocation of free_irq() would trigger the above > warning call trace. To fix this issue, set the lineevent_state::irq > after the IRQ register successfully. > > Fixes: 468242724143 ("gpiolib: cdev: refactor lineevent cleanup into lineevent_free") > Cc: stable@vger.kernel.org > Signed-off-by: Meng Li > --- > drivers/gpio/gpiolib-cdev.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c > index ffa0256cad5a..937e7a8dd8a9 100644 > --- a/drivers/gpio/gpiolib-cdev.c > +++ b/drivers/gpio/gpiolib-cdev.c > @@ -1784,7 +1784,6 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) > ret = -ENODEV; > goto out_free_le; > } > - le->irq = irq; > > if (eflags & GPIOEVENT_REQUEST_RISING_EDGE) > irqflags |= test_bit(FLAG_ACTIVE_LOW, &desc->flags) ? > @@ -1798,7 +1797,7 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) > init_waitqueue_head(&le->wait); > > /* Request a thread to read the events */ > - ret = request_threaded_irq(le->irq, > + ret = request_threaded_irq(irq, > lineevent_irq_handler, > lineevent_irq_thread, > irqflags, > @@ -1807,6 +1806,8 @@ static int lineevent_create(struct gpio_device *gdev, void __user *ip) > if (ret) > goto out_free_le; > > + le->irq = irq; > + > fd = get_unused_fd_flags(O_RDONLY | O_CLOEXEC); > if (fd < 0) { > ret = fd; > -- > 2.36.1 > Applied, thanks! Bart