Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp3754146rdh; Tue, 28 Nov 2023 03:03:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IF2+nQKYViU51zP9n17vBphvGyTNBhnEoJjA0StwnOTZxSPLmjVptVcNcbK5YWbJN4qBl28 X-Received: by 2002:a05:6a00:244a:b0:6cb:a2f7:83d with SMTP id d10-20020a056a00244a00b006cba2f7083dmr17280449pfj.19.1701169380712; Tue, 28 Nov 2023 03:03:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701169380; cv=none; d=google.com; s=arc-20160816; b=TzAOpLhNOK6IZ2cAPLLiW5l0xFicqNv9YYANuHsMR9oG1+D/YOO7YT2YufnoK8CDhd oAnK/Ub0FrfSbqmEATUpqTIAbHbf1zSVrgzYktuhQM+e/TA9EHX8SHLvluf3VNln0nC1 LAX5CiPzhdPDO8gkzFkyPZiixQpHnB9QtGNRhPTZKFePppZiHN5AWItyICLv1q/Pfq8g W6SqIwXkmQ0sMVM/o6ss1XQglmFIgQ3iG4OnMYTrdTib8S5BqMgvhxUyMT4JJY0am/XV duQ1j7hEERygWsfgNThWe4dfSpcpRbtSrNzQ/AmpxSN8fbr6wvs5pI+unm5PK7vIPjTv 1mKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=oDdeUFllCI6cz5ZamrullL8d06k38FlFlbto7fVB9l4=; fh=1Vgnp4rduMUW7amFAIzLixMhmpAAJHd2dwN6fEYngHc=; b=SesFKEK5HKe/uGM6cIJbicV2x61/++P6sUaW0v6JDbVDa+wFa9u/2ACFX8l3IsqqFn YOIqDyTaIJpTENoM7QvpcEW7wOcDKBW6vzyDxFcRJ8PfH4uPlzBqQlZE5FIl6NsbKaY3 KjyOxW9DTf7dkteVFa38LJ1GNK5EMY21bdx4ithljIcRZjGcfGufhlKbf4NRNYPFolN9 hv25GLl8KlaWDWNqg0bqe2Vw7L4qVMKi/dnlmhJ2JNoc9puhdNqfkLmwPX+Crr2qrzBO AChtPANgxjYf78/5jrFCBYrO5fBc/IC+EIDB8GrTciZc+euhIz5aWKnByONhtKP7oAz9 Xgqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="B4m/PFfa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id f24-20020a63dc58000000b005b9293fcf78si12055918pgj.10.2023.11.28.03.02.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Nov 2023 03:03:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="B4m/PFfa"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 699E3805A789; Tue, 28 Nov 2023 03:02:53 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344466AbjK1Kzz (ORCPT + 99 others); Tue, 28 Nov 2023 05:55:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344189AbjK1Kzm (ORCPT ); Tue, 28 Nov 2023 05:55:42 -0500 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 391FB189; Tue, 28 Nov 2023 02:55:46 -0800 (PST) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-6c4eb5fda3cso5281351b3a.2; Tue, 28 Nov 2023 02:55:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701168945; x=1701773745; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=oDdeUFllCI6cz5ZamrullL8d06k38FlFlbto7fVB9l4=; b=B4m/PFfa51fSzsZGi09BtmtawHjidxBuaPIJEj4eHWLt2uldpHfh8fI6CiuzcshL4L /lMqMVd3aEacZh59TeNCpGRdlC0rexSRIVhFi0Hry6n9GHF6xZKns0f2LWtIYx3IoJFO /XP5sdAWGR1kxS3V+5C4E9Jqoy/FpD2RrEPGG0ODCkvoeD8r4B2Xd64DsuTemUU0vY2t IcKm0vXjZzjxyiffMWGWUEITB+xoUAXfySZMevh2Gch2iAnDVyMKJaKDByPGyparw0Jb x3OH0khQsZIcwU4M0yqCK/JNnIUZhptwsfzHTTOqwJDUc8QLPYQ/31Lm3+UdqK4ltBxh /QOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701168945; x=1701773745; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oDdeUFllCI6cz5ZamrullL8d06k38FlFlbto7fVB9l4=; b=iiVweCLVcP8Rindxxgf4sgp1exw0+M19hy0tcp+WoSkTN1r7PzPMaONo5zLRTn5fHr Bya9iQCsCVtF+cDphmQx1hFwUJ6sYvrrF2DYYTO3m5pJI5iq5u1OGrpBqm1rPPzEbqTY hR7OYMGhh9E4mZzivBNEXx9C6Pu+f6XGGi25ExOYNWUAg++VxONKk96gZENvt3ooNmva 1aooTYWLt7PZL/gMZI2yauRdTadzQYdqjxCI5ed5Xw3w3uOVwc8Zr4yzws2dFbjLo/NW 9K3Gw8kQNHe5h6sVW5SMcsQ2lg1CCVagPvj+LAx+qsGQnJd+j+90pOF81i6X8qCP7yJE A+EA== X-Gm-Message-State: AOJu0YzkUwW5xLnwMZwW5ZbnMKup//GSEUMKENv2XoaWOqWuREz15H5R HWyRRRHQU5KlyGa9B4ysqdnqV8QQePuUzy5fsak= X-Received: by 2002:a05:6a20:72a5:b0:18c:1d42:4e13 with SMTP id o37-20020a056a2072a500b0018c1d424e13mr15539521pzk.25.1701168945526; Tue, 28 Nov 2023 02:55:45 -0800 (PST) MIME-Version: 1.0 References: <20231123132749.108827-1-boerge.struempfel@gmail.com> In-Reply-To: From: =?UTF-8?B?QsO2cmdlIFN0csO8bXBmZWw=?= Date: Tue, 28 Nov 2023 11:55:34 +0100 Message-ID: Subject: Re: [PATCH] gpiolib: sysfs: Fix improper error handling on failed export To: Andy Shevchenko Cc: Linus Walleij , Bartosz Golaszewski , Andy Shevchenko , linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, bstruempfel@ultratronik.de Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 28 Nov 2023 03:02:53 -0800 (PST) Hi Andy, On Thu, Nov 23, 2023 at 4:01=E2=80=AFPM B=C3=B6rge Str=C3=BCmpfel wrote: > > Hi Andy > > thank you for your feedback > > On Thu, Nov 23, 2023 at 3:25=E2=80=AFPM Andy Shevchenko > wrote: > > > > On Thu, Nov 23, 2023 at 3:30=E2=80=AFPM Boerge Struempfel > > wrote: > > > > > > If gpio_set_transitory fails, we should free the gpio again. Most > > > > We refer to functions as func() in the text and comments (note parenthe= ses). > > > > GPIO > > Thanks for letting me know, I will update the the commit message in > regards to this. > > > > > > notably, the flag FLAG_REQUESTED has previously been set in > > > gpiod_request_commit, and should be reset on failure. > > > > Same about func(). > > > > ... > > > > Seems the correct fix, but you may also add that no existing user is > > returning anything except 0 or ENOTSUPP that is converted to 0 in > > GPIOLIB core code. Hence no Fixes tag is needed, but still possible if > > maintainers want it. > > > > You are right. For now, all mainline users are returning 0. We only found > this due to downstream-specific code. I'll add a comment about this not > affecting any existing users to the commit message. > A small update: I looked through the possible users again, and there seems to be at least the possibility for some other return values. The reason for this is, that the .set_config() of the specific gpio driver is called during the gpiod_set_transitory() call. For example the .set_config() of gpio-aspeed might in certain (somewhat unlikely) cases return -EPROBE_DEFER as well as -EINVAL. However I don't think, that these conditional paths can be reached on a properly configured system. Kind Regards, B=C3=B6rge Str=C3=BCmpfel