From nobody Fri Feb 13 00:20:38 2026 Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4BF114F10F for ; Fri, 3 Jan 2025 03:04:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735873456; cv=none; b=ON9o3LuEhtBeZULnZOzC3WZGJY6hUNDr9QKeHwXIAsTz8TEhAertlg8ds4zgKuSMj+LPb6FLVPKN9sEbQrpoLBJUBlbtMB9wzkNaiLkoni6ooRHDIw1vX1CwadM3dRtia851tXZgmGtcdcdlKu7D1i02yxPTyuvYzTb/RbIaB2s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735873456; c=relaxed/simple; bh=HO08RPGJzed4ppqZ+jQm2FIefTr2FHu7Tv13x0myX08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ADUTptx4QhWKSaN27qFrSIQkHpjNh9tf0+rvmCNVJ1fZZfm+P28lPoBU1mkIr1EKGxVVtBnMehM2aDp23YGaD4W32CeqyMrBuCaItKsujO9UadI+5MYQkT2ICphhtH+wxmlpSENWV6gSnHiWw+HoYcQedDVMDNlDAlmF3pUyrR0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=GLFN9/qN; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="GLFN9/qN" Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 1BAA140FAA for ; Fri, 3 Jan 2025 03:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1735873453; bh=cksCAqWYBujQdwWe5V+2vXqBxqUQWT0G6DdOeqkhr9I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GLFN9/qNHUFeUq9D3fSckxDWCb8jr8Pi8Lf+Qm+mpDfVSSpAuqqOLh176MQWGtQ3z VBPX3ictp1ShjiB5/rTDyyAf5SBQZhptH9oMyYguM3GXwMIH6hsDjxx8p/N38+nNAW uN3q3tId0jb5fI01GgYfQsdiiYD1A+mwqjwWAXTOn89VwNeNo7cJOGE6LQib52GWup k9O6VpcdRzkwFyUn6Ne/QQQsJ4vX/SBR6ib4hjd6o0bHWld9colFV+uoT8/CmsBNnw 1aIgmgLtQXrfcXR8S2Ybm5SNyqOJaTrjFyvHMcB8eq10aZoFEecaqNZkGslbSs2muY WzAa+5vv4kA9Q== Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2165433e229so164523115ad.1 for ; Thu, 02 Jan 2025 19:04:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735873452; x=1736478252; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cksCAqWYBujQdwWe5V+2vXqBxqUQWT0G6DdOeqkhr9I=; b=VgjhGwUHMkd8ZNv+7LpQXBvSmKtH7Lm02meHdaNLiHSCqizUSVDHaEvRZsyUn+Jmdj ylejpVZDW6CS0DxSkWcc6qG88difxKINZx33ybZIZS9xn3M1KZP39mP/c4/1CkvGNxJ0 PZZhBif7/tQzQODdeUh/iln3eB66/dAIvs9X0JYVjQ2XeiayVyV56oykXr1f8+Id2j/q 0cZPpt1mlVoMKvay6bT1EerI7TjtOqAaAZwf5wjYzQNgTw6j4N+2zOgHTFGI30kXrrKc lKRcq1SFrLsXaHfEKSIGVuSiiqVOFrJWtEVnu4sLiLeiYcwRvug61/QC5jJtl5vt7tGZ kzcw== X-Forwarded-Encrypted: i=1; AJvYcCU/186v8lwP+7FCwcNFwyS/v+eAMEvev1D5MJT4J+snNrpBJm8MnWGMqogBkfvOuk7YFNGZ3SG5NLjTk/s=@vger.kernel.org X-Gm-Message-State: AOJu0YyR3vW6KoQg5VpluDTuC+DVX8ccpazB5IyWM+yiDsGaNYNeMDyz ZUaWlcy4y0HwlXmzGA246t8xB+Nhbva96EK1hKsm0eblvqv1J9OqB6n5icaizFJKPC62SuOU6zp veuyy5sRkKjr/JvN86/JsW6k2Vx3t+hTrBf0+W0XZYE1fg/IkZWebPrI9FiEq54ICtr+OIlVss0 edpQ== X-Gm-Gg: ASbGncuIw/QKu16BULFElCY3mZVK3KB9tnDwJjp8hccpcUO510xiih9D3xSzUkRM92l 18ReBkdn2oeS4rrpDgkB7y1tiZCABovsWJQW6isH7SpIc+DL5RysklyV28zBNwVI0tuXsxKgBXl Z7yvBuuIAa7vHKNdCR21QtzLjRScvAIFzlwDRt2aH7sTo2UzMnrnkvKHtewjfmRrjIXht8gcqlJ to+fK/SobboioSSTxO2NNEBHKRNeq5OIotHuU0R2P85yC6O7h/BGqhs7Q== X-Received: by 2002:a17:902:ceca:b0:215:83e1:99ff with SMTP id d9443c01a7336-219e6eb3a33mr565079075ad.27.1735873451772; Thu, 02 Jan 2025 19:04:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IHGBER2IvdTscZDfzvf/elpBjJTjHsAhRcm73v7vt/2knmlf2lYW0VN6rGpYrctLrSfO1co+w== X-Received: by 2002:a17:902:ceca:b0:215:83e1:99ff with SMTP id d9443c01a7336-219e6eb3a33mr565078855ad.27.1735873451426; Thu, 02 Jan 2025 19:04:11 -0800 (PST) Received: from z790sl.. ([240f:74:7be:1:cb9e:69af:fb16:54f4]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-219dc964e92sm234468215ad.18.2025.01.02.19.04.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Jan 2025 19:04:11 -0800 (PST) From: Koichiro Den To: linux-gpio@vger.kernel.org Cc: linus.walleij@linaro.org, brgl@bgdev.pl, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/4] gpio: virtuser: fix missing lookup table cleanups Date: Fri, 3 Jan 2025 12:03:59 +0900 Message-ID: <20250103030402.81954-2-koichiro.den@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250103030402.81954-1-koichiro.den@canonical.com> References: <20250103030402.81954-1-koichiro.den@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" When a virtuser device is created via configfs and the probe fails due to an incorrect lookup table, the table is not removed. This prevents subsequent probe attempts from succeeding, even if the issue is corrected, unless the device is released. Additionally, cleanup is also needed in the less likely case of platform_device_register_full() failure. Ensure the lookup table is removed whenever the device activation fails. Fixes: 91581c4b3f29 ("gpio: virtuser: new virtual testing driver for the GP= IO API") Signed-off-by: Koichiro Den --- drivers/gpio/gpio-virtuser.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/drivers/gpio/gpio-virtuser.c b/drivers/gpio/gpio-virtuser.c index 91b6352c957c..ec5abfebca3d 100644 --- a/drivers/gpio/gpio-virtuser.c +++ b/drivers/gpio/gpio-virtuser.c @@ -1487,10 +1487,8 @@ gpio_virtuser_device_activate(struct gpio_virtuser_d= evice *dev) pdevinfo.fwnode =3D swnode; =20 ret =3D gpio_virtuser_make_lookup_table(dev); - if (ret) { - fwnode_remove_software_node(swnode); - return ret; - } + if (ret) + goto err_remove_swnode; =20 reinit_completion(&dev->probe_completion); dev->driver_bound =3D false; @@ -1498,23 +1496,32 @@ gpio_virtuser_device_activate(struct gpio_virtuser_= device *dev) =20 pdev =3D platform_device_register_full(&pdevinfo); if (IS_ERR(pdev)) { + ret =3D PTR_ERR(pdev); bus_unregister_notifier(&platform_bus_type, &dev->bus_notifier); - fwnode_remove_software_node(swnode); - return PTR_ERR(pdev); + goto err_remove_lookup_table; } =20 wait_for_completion(&dev->probe_completion); bus_unregister_notifier(&platform_bus_type, &dev->bus_notifier); =20 if (!dev->driver_bound) { - platform_device_unregister(pdev); - fwnode_remove_software_node(swnode); - return -ENXIO; + ret =3D -ENXIO; + goto err_unregister_pdev; } =20 dev->pdev =3D pdev; =20 return 0; + +err_unregister_pdev: + platform_device_unregister(pdev); +err_remove_lookup_table: + gpiod_remove_lookup_table(dev->lookup_table); + kfree(dev->lookup_table); +err_remove_swnode: + fwnode_remove_software_node(swnode); + + return ret; } =20 static void --=20 2.43.0