Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/2196254/?format=api
{ "id": 2196254, "url": "http://patchwork.ozlabs.org/api/patches/2196254/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/patch/20260213092958.864411-11-tzungbi@kernel.org/", "project": { "id": 42, "url": "http://patchwork.ozlabs.org/api/projects/42/?format=api", "name": "Linux GPIO development", "link_name": "linux-gpio", "list_id": "linux-gpio.vger.kernel.org", "list_email": "linux-gpio@vger.kernel.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20260213092958.864411-11-tzungbi@kernel.org>", "list_archive_url": null, "date": "2026-02-13T09:29:57", "name": "[v3,10/11] gpio: Leverage revocable for accessing struct gpio_chip", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "3387b107fa9677c7d12a8b87a6d5304dc5bc9fb2", "submitter": { "id": 83557, "url": "http://patchwork.ozlabs.org/api/people/83557/?format=api", "name": "Tzung-Bi Shih", "email": "tzungbi@kernel.org" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/linux-gpio/patch/20260213092958.864411-11-tzungbi@kernel.org/mbox/", "series": [ { "id": 492068, "url": "http://patchwork.ozlabs.org/api/series/492068/?format=api", "web_url": "http://patchwork.ozlabs.org/project/linux-gpio/list/?series=492068", "date": "2026-02-13T09:29:47", "name": "gpio: Adopt revocable mechanism for UAF prevention", "version": 3, "mbox": "http://patchwork.ozlabs.org/series/492068/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/2196254/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/2196254/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "\n <linux-gpio+bounces-31667-incoming=patchwork.ozlabs.org@vger.kernel.org>", "X-Original-To": [ "incoming@patchwork.ozlabs.org", "linux-gpio@vger.kernel.org" ], "Delivered-To": "patchwork-incoming@legolas.ozlabs.org", "Authentication-Results": [ "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256\n header.s=k20201202 header.b=GMBJTlbQ;\n\tdkim-atps=neutral", "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c0a:e001:db::12fc:5321; helo=sea.lore.kernel.org;\n envelope-from=linux-gpio+bounces-31667-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)", "smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=\"GMBJTlbQ\"", "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=10.30.226.201" ], "Received": [ "from sea.lore.kernel.org (sea.lore.kernel.org\n [IPv6:2600:3c0a:e001:db::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fC6Vb4ggDz1xpl\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 20:36:07 +1100 (AEDT)", "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 8F03831A233C\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 13 Feb 2026 09:31:33 +0000 (UTC)", "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 478972D9EC5;\n\tFri, 13 Feb 2026 09:31:33 +0000 (UTC)", "from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org\n [10.30.226.201])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id 054A6330B27;\n\tFri, 13 Feb 2026 09:31:32 +0000 (UTC)", "by smtp.kernel.org (Postfix) with ESMTPSA id 1B14AC16AAE;\n\tFri, 13 Feb 2026 09:31:29 +0000 (UTC)" ], "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1770975093; cv=none;\n b=lMuU3q2AyKp8k36+GrBMq6QPeZ2KzH5elRSW1SmgqI1idNsZ/TVMRA6N7arG3+IgUbIS8FNCv0dTtnWzaHHZJUKi+EOEgpEPxDuzOGGHY54E5Vi6KsLKMoV2e4didmCBrFhDISRp6b/XkzVGUiptaHdy+BTivOH5PDiFMMrgd+M=", "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1770975093; c=relaxed/simple;\n\tbh=sc68Y2yfU7vJPsAs/fppEoHXv0dQsgkbHlyNAxyY/KQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=RLFvViXWw5NgbOZRh7Jva5EqYlTRe390bhOWO6p8qi06mPYWmlC7+Z0wd9cSTI21GOWdMgCT7l/JyRy8ZGNfXlhzBwB++WSnYrJX8zlfwPSpQWBb4/NyDXh1omHGpdIqJlJqtgFyHRSvWNY4KOCInFP/urJd70QFp1tZrb0dhZk=", "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org\n header.b=GMBJTlbQ; arc=none smtp.client-ip=10.30.226.201", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org;\n\ts=k20201202; t=1770975092;\n\tbh=sc68Y2yfU7vJPsAs/fppEoHXv0dQsgkbHlyNAxyY/KQ=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=GMBJTlbQSoMbGuLvCNfO7N884adZYuIlKQDbzSiU0o0QVR9nSSFfFkPx3UCogq+Cn\n\t XfVQvFDnmcL7soAQnDHouOcYXVZj9vLWi6o/C5dPDbOkmAV8e1TEUeD6fV7Qj+7ZKg\n\t e6+Flw5JWGIplEsm/fjknKLfax9HvXiwosZgo9Lk+k3iWSciFPAac40Ft7F6TpuXxo\n\t fJXByL2vGxWf+nFpeCxRkw3FdSBOXcNgl40TdXxSobPLET9YD2sc5ls4X9cWBa0deF\n\t Nk/KvyZuCYE9fmkHfzEcxVC6KI0+IRN7DifOT/DZEB/Dro+wbdfO8iP/FXf0MiraVZ\n\t 27JpTACoiU5Og==", "From": "Tzung-Bi Shih <tzungbi@kernel.org>", "To": "Bartosz Golaszewski <brgl@kernel.org>,\n\tLinus Walleij <linusw@kernel.org>", "Cc": "Greg Kroah-Hartman <gregkh@linuxfoundation.org>,\n\t\"Rafael J. Wysocki\" <rafael@kernel.org>,\n\tDanilo Krummrich <dakr@kernel.org>,\n\tJonathan Corbet <corbet@lwn.net>,\n\tShuah Khan <shuah@kernel.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tWolfram Sang <wsa+renesas@sang-engineering.com>,\n\tJason Gunthorpe <jgg@nvidia.com>,\n\tJohan Hovold <johan@kernel.org>,\n\t\"Paul E . McKenney\" <paulmck@kernel.org>,\n\tDan Williams <dan.j.williams@intel.com>,\n\tchrome-platform@lists.linux.dev,\n\ttzungbi@kernel.org,\n\tlinux-gpio@vger.kernel.org,\n\tlinux-kselftest@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org", "Subject": "[PATCH v3 10/11] gpio: Leverage revocable for accessing struct\n gpio_chip", "Date": "Fri, 13 Feb 2026 09:29:57 +0000", "Message-ID": "<20260213092958.864411-11-tzungbi@kernel.org>", "X-Mailer": "git-send-email 2.53.0.310.g728cabbaf7-goog", "In-Reply-To": "<20260213092958.864411-1-tzungbi@kernel.org>", "References": "<20260213092958.864411-1-tzungbi@kernel.org>", "Precedence": "bulk", "X-Mailing-List": "linux-gpio@vger.kernel.org", "List-Id": "<linux-gpio.vger.kernel.org>", "List-Subscribe": "<mailto:linux-gpio+subscribe@vger.kernel.org>", "List-Unsubscribe": "<mailto:linux-gpio+unsubscribe@vger.kernel.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit" }, "content": "Struct gpio_device now provides a revocable provider to the underlying\nstruct gpio_chip. Leverage revocable for accessing the struct\ngpio_chip.\n\nSigned-off-by: Tzung-Bi Shih <tzungbi@kernel.org>\n---\nv3:\n- Change revocable API usages accordingly.\n\nv2: https://lore.kernel.org/all/20260203061059.975605-11-tzungbi@kernel.org\n- Separate from v1(a) for excluding gpio_chip_guard and combine v1(b).\n\nv1(a):\n- https://lore.kernel.org/all/20260116081036.352286-23-tzungbi@kernel.org\nv1(b):\n- https://lore.kernel.org/all/20260116081036.352286-19-tzungbi@kernel.org\n\n drivers/gpio/gpiolib.c | 60 +++++++++++++-----------------------------\n 1 file changed, 18 insertions(+), 42 deletions(-)", "diff": "diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c\nindex 34f2665a9311..2ba78add3417 100644\n--- a/drivers/gpio/gpiolib.c\n+++ b/drivers/gpio/gpiolib.c\n@@ -338,7 +338,10 @@ EXPORT_SYMBOL(gpio_device_get_label);\n */\n struct gpio_chip *gpio_device_get_chip(struct gpio_device *gdev)\n {\n-\treturn rcu_dereference_check(gdev->chip, 1);\n+\tstruct gpio_chip *gc;\n+\n+\trevocable_try_access_with(gdev->chip_rp, gc);\n+\treturn gc;\n }\n EXPORT_SYMBOL_GPL(gpio_device_get_chip);\n \n@@ -556,9 +559,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)\n \n \tlist_for_each_entry_srcu(gdev, &gpio_devices, list,\n \t\t\t\t srcu_read_lock_held(&gpio_devices_srcu)) {\n-\t\tguard(srcu)(&gdev->srcu);\n-\n-\t\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n+\t\trevocable_try_access_with(gdev->chip_rp, gc);\n \t\tif (!gc)\n \t\t\tcontinue;\n \n@@ -972,9 +973,7 @@ static void gpiochip_setup_devs(void)\n \n \tlist_for_each_entry_srcu(gdev, &gpio_devices, list,\n \t\t\t\t srcu_read_lock_held(&gpio_devices_srcu)) {\n-\t\tguard(srcu)(&gdev->srcu);\n-\n-\t\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n+\t\trevocable_try_access_with(gdev->chip_rp, gc);\n \t\tif (!gc) {\n \t\t\tdev_err(&gdev->dev, \"Underlying GPIO chip is gone\\n\");\n \t\t\tcontinue;\n@@ -1378,11 +1377,11 @@ struct gpio_device *gpio_device_find(const void *data,\n \t\tif (!device_is_registered(&gdev->dev))\n \t\t\tcontinue;\n \n-\t\tguard(srcu)(&gdev->srcu);\n-\n-\t\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n+\t\trevocable_try_access_with(gdev->chip_rp, gc);\n+\t\tif (!gc)\n+\t\t\tcontinue;\n \n-\t\tif (gc && match(gc, data))\n+\t\tif (match(gc, data))\n \t\t\treturn gpio_device_get(gdev);\n \t}\n \n@@ -3310,18 +3309,10 @@ static int gpio_chip_get_value(struct gpio_chip *gc, const struct gpio_desc *des\n \n static int gpiod_get_raw_value_commit(const struct gpio_desc *desc)\n {\n-\tstruct gpio_device *gdev;\n \tstruct gpio_chip *gc;\n \tint value;\n \n-\t/* FIXME Unable to use gpio_chip_guard due to const desc. */\n-\tgdev = desc->gdev;\n-\n-\tguard(srcu)(&gdev->srcu);\n-\n-\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n-\tif (!gc)\n-\t\treturn -ENODEV;\n+\trevocable_try_access_or_return(desc->gdev->chip_rp, gc);\n \n \tvalue = gpio_chip_get_value(gc, desc);\n \tvalue = value < 0 ? value : !!value;\n@@ -3360,9 +3351,10 @@ static int gpio_chip_get_multiple(struct gpio_chip *gc,\n /* The 'other' chip must be protected with its GPIO device's SRCU. */\n static bool gpio_device_chip_cmp(struct gpio_device *gdev, struct gpio_chip *gc)\n {\n-\tguard(srcu)(&gdev->srcu);\n+\tstruct gpio_chip *chip;\n \n-\treturn gc == srcu_dereference(gdev->chip, &gdev->srcu);\n+\trevocable_try_access_with(gdev->chip_rp, chip);\n+\treturn chip ? chip == gc : false;\n }\n \n int gpiod_get_array_value_complex(bool raw, bool can_sleep,\n@@ -3385,11 +3377,7 @@ int gpiod_get_array_value_complex(bool raw, bool can_sleep,\n \t\tif (!can_sleep)\n \t\t\tWARN_ON(array_info->gdev->can_sleep);\n \n-\t\tguard(srcu)(&array_info->gdev->srcu);\n-\t\tgc = srcu_dereference(array_info->gdev->chip,\n-\t\t\t\t &array_info->gdev->srcu);\n-\t\tif (!gc)\n-\t\t\treturn -ENODEV;\n+\t\trevocable_try_access_or_return(array_info->gdev->chip_rp, gc);\n \n \t\tret = gpio_chip_get_multiple(gc, array_info->get_mask,\n \t\t\t\t\t value_bitmap);\n@@ -3726,11 +3714,7 @@ int gpiod_set_array_value_complex(bool raw, bool can_sleep,\n \t\t\t\treturn -EPERM;\n \t\t}\n \n-\t\tguard(srcu)(&array_info->gdev->srcu);\n-\t\tgc = srcu_dereference(array_info->gdev->chip,\n-\t\t\t\t &array_info->gdev->srcu);\n-\t\tif (!gc)\n-\t\t\treturn -ENODEV;\n+\t\trevocable_try_access_or_return(array_info->gdev->chip_rp, gc);\n \n \t\tif (!raw && !bitmap_empty(array_info->invert_mask, array_size))\n \t\t\tbitmap_xor(value_bitmap, value_bitmap,\n@@ -4024,7 +4008,6 @@ EXPORT_SYMBOL_GPL(gpiod_is_shared);\n */\n int gpiod_to_irq(const struct gpio_desc *desc)\n {\n-\tstruct gpio_device *gdev;\n \tstruct gpio_chip *gc;\n \tint offset;\n \tint ret;\n@@ -4033,12 +4016,7 @@ int gpiod_to_irq(const struct gpio_desc *desc)\n \tif (ret <= 0)\n \t\treturn -EINVAL;\n \n-\tgdev = desc->gdev;\n-\t/* FIXME Cannot use gpio_chip_guard due to const desc. */\n-\tguard(srcu)(&gdev->srcu);\n-\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n-\tif (!gc)\n-\t\treturn -ENODEV;\n+\trevocable_try_access_or_return(desc->gdev->chip_rp, gc);\n \n \toffset = gpiod_hwgpio(desc);\n \tif (gc->to_irq) {\n@@ -5413,9 +5391,7 @@ static int gpiolib_seq_show(struct seq_file *s, void *v)\n \tif (priv->newline)\n \t\tseq_putc(s, '\\n');\n \n-\tguard(srcu)(&gdev->srcu);\n-\n-\tgc = srcu_dereference(gdev->chip, &gdev->srcu);\n+\trevocable_try_access_with(gdev->chip_rp, gc);\n \tif (!gc) {\n \t\tseq_printf(s, \"%s: (dangling chip)\\n\", dev_name(&gdev->dev));\n \t\treturn 0;\n", "prefixes": [ "v3", "10/11" ] }