{"id":2221303,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221303/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260409072214.164971-1-rob_garcia@163.com/","project":{"id":42,"url":"http://patchwork.ozlabs.org/api/1.1/projects/42/?format=json","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":""},"msgid":"<20260409072214.164971-1-rob_garcia@163.com>","date":"2026-04-09T07:22:14","name":"[5.15.y] gpiolib: cdev: fix uninitialised kfifo","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"211758160f17acc1e9157fddfa0f6ae88bbda0d8","submitter":{"id":93097,"url":"http://patchwork.ozlabs.org/api/1.1/people/93097/?format=json","name":"Robert Garcia","email":"rob_garcia@163.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-gpio/patch/20260409072214.164971-1-rob_garcia@163.com/mbox/","series":[{"id":499244,"url":"http://patchwork.ozlabs.org/api/1.1/series/499244/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-gpio/list/?series=499244","date":"2026-04-09T07:22:14","name":"[5.15.y] gpiolib: cdev: fix uninitialised kfifo","version":1,"mbox":"http://patchwork.ozlabs.org/series/499244/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221303/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221303/checks/","tags":{},"headers":{"Return-Path":"\n <linux-gpio+bounces-34913-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 (1024-bit key;\n unprotected) header.d=163.com header.i=@163.com header.a=rsa-sha256\n header.s=s110527 header.b=HCuqhN23;\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-34913-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=163.com header.i=@163.com\n header.b=\"HCuqhN23\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=117.135.210.2","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=163.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=163.com"],"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 4frs0h3Jyyz1yD3\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 17:25:40 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id 8102B303661C\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  9 Apr 2026 07:22:39 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id D6EDA3793AA;\n\tThu,  9 Apr 2026 07:22:38 +0000 (UTC)","from m16.mail.163.com (m16.mail.163.com [117.135.210.2])\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 5F8A5371063;\n\tThu,  9 Apr 2026 07:22:34 +0000 (UTC)","from pek-lpg-core5.wrs.com (unknown [])\n\tby gzga-smtp-mtada-g0-0 (Coremail) with SMTP id\n _____wCXsa2mU9dpXL5fDw--.60815S2;\n\tThu, 09 Apr 2026 15:22:16 +0800 (CST)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775719358; cv=none;\n b=JezXS6qjYkBsoi71WIu3n7uy/hq8F+Vkm41vnL4fHrDY+23vIZ7p8cuG49rMgUkRO5XrEgediF2WT8fApz/OLLn8X8BrkTFV8nRCqBuKT5KSssxU+XkTG5ykW2y37tOtHppDStYF8CsX10z9wMOIJV7zsTBA1NILleAMHAn8oME=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775719358; c=relaxed/simple;\n\tbh=uG73nu9hZqiUQm8fuGJfOeHuM7E6GJFt0gE+Y+A7xtI=;\n\th=From:To:Cc:Subject:Date:Message-Id:MIME-Version;\n b=WOeOvI1XOeXSBZP/O3M8p+74T4prY72t34cN6OvqmMULKl+GRvdet9eGc7iv30v4TXaM2tEl6hnFiQRNAUuw0eauyUtM0cTSqw1tko+foBeNrOYUjSbsjVxXZsrpqWPMG2CpFT9ff8rwYxbBdHLsqbu44SxykAX/gWdB3fPak0o=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=163.com;\n spf=pass smtp.mailfrom=163.com;\n dkim=pass (1024-bit key) header.d=163.com header.i=@163.com\n header.b=HCuqhN23; arc=none smtp.client-ip=117.135.210.2","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com;\n\ts=s110527; h=From:To:Subject:Date:Message-Id:MIME-Version; bh=Ix\n\teCLXd2qgXHzwKPvCTFfj8A0JjMaFnvXAu/L8gz2AU=; b=HCuqhN23j/HLwAwgdz\n\tfX+2cMfJH542hXntrPL9u0PEUpTHMM/Od4OTBxdqfw9c96U0VLwnyLRhATIxvjrT\n\tHnoAiesFPDKG+uu0zeCddhY09U8nrOWLu+08Cp+tiMmr2Zm2ESQOabrkiJUICUr/\n\tBdzdj17T4L8t8mgmIC2we9rvA=","From":"Robert Garcia <rob_garcia@163.com>","To":"stable@vger.kernel.org,\n\tKent Gibson <warthog618@gmail.com>","Cc":"Bartosz Golaszewski <bartosz.golaszewski@linaro.org>,\n\tRobert Garcia <rob_garcia@163.com>,\n\tLinus Walleij <linus.walleij@linaro.org>,\n\tBartosz Golaszewski <brgl@bgdev.pl>,\n\tlinux-gpio@vger.kernel.org,\n\tlinux-kernel@vger.kernel.org","Subject":"[PATCH 5.15.y] gpiolib: cdev: fix uninitialised kfifo","Date":"Thu,  9 Apr 2026 15:22:14 +0800","Message-Id":"<20260409072214.164971-1-rob_garcia@163.com>","X-Mailer":"git-send-email 2.34.1","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","X-CM-TRANSID":"_____wCXsa2mU9dpXL5fDw--.60815S2","X-Coremail-Antispam":"1Uf129KBjvJXoW7AF4Uuw4DtrW3AFy3uF4kZwb_yoW8ZF43p3\n\ty7K3W5trn7tFyxW3y5Za1fZFZY9aykGr9I9rW7K347uF17JF9FyFW8AFy3uF45WFZ5Cr1Y\n\tvF45AFnxuF1FkaDanT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2\n\t9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0piG-ntUUUUU=","X-CM-SenderInfo":"5uresw5dufxti6rwjhhfrp/xtbC5QhPumnXU6gKXwAA3I"},"content":"From: Kent Gibson <warthog618@gmail.com>\n\n[ Upstream commit ee0166b637a5e376118e9659e5b4148080f1d27e ]\n\nIf a line is requested with debounce, and that results in debouncing\nin software, and the line is subsequently reconfigured to enable edge\ndetection then the allocation of the kfifo to contain edge events is\noverlooked.  This results in events being written to and read from an\nuninitialised kfifo.  Read events are returned to userspace.\n\nInitialise the kfifo in the case where the software debounce is\nalready active.\n\nFixes: 65cff7046406 (\"gpiolib: cdev: support setting debounce\")\nSigned-off-by: Kent Gibson <warthog618@gmail.com>\nLink: https://lore.kernel.org/r/20240510065342.36191-1-warthog618@gmail.com\nSigned-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>\nSigned-off-by: Robert Garcia <rob_garcia@163.com>\n---\n drivers/gpio/gpiolib-cdev.c | 13 +++++++++++++\n 1 file changed, 13 insertions(+)","diff":"diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c\nindex 3cd19ab1fc2a..d4b221c90bb2 100644\n--- a/drivers/gpio/gpiolib-cdev.c\n+++ b/drivers/gpio/gpiolib-cdev.c\n@@ -896,6 +896,7 @@ static int edge_detector_update(struct line *line,\n \t\t\t\tunsigned int line_idx,\n \t\t\t\tu64 eflags, bool polarity_change)\n {\n+\tint ret;\n \tunsigned int debounce_period_us =\n \t\tgpio_v2_line_config_debounce_period(lc, line_idx);\n \n@@ -907,6 +908,18 @@ static int edge_detector_update(struct line *line,\n \tif (debounce_period_us && READ_ONCE(line->sw_debounced)) {\n \t\tWRITE_ONCE(line->eflags, eflags);\n \t\tWRITE_ONCE(line->desc->debounce_period_us, debounce_period_us);\n+\t\t/*\n+\t\t * ensure event fifo is initialised if edge detection\n+\t\t * is now enabled.\n+\t\t */\n+\t\teflags = eflags & GPIO_V2_LINE_EDGE_FLAGS;\n+\t\tif (eflags && !kfifo_initialized(&line->req->events)) {\n+\t\t\tret = kfifo_alloc(&line->req->events,\n+\t\t\t\t\t  line->req->event_buffer_size,\n+\t\t\t\t\t  GFP_KERNEL);\n+\t\t\tif (ret)\n+\t\t\t\treturn ret;\n+\t\t}\n \t\treturn 0;\n \t}\n \n","prefixes":["5.15.y"]}