Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2588446rdb; Mon, 4 Dec 2023 01:36:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IEnTgwZR0YJVoJRcqenz0EN1L3ATEy5YjgQBa3qvqMN2F6SI2WX5vNkTXJfE9K0ORy1SlLL X-Received: by 2002:a05:6870:1688:b0:1fb:75b:99a8 with SMTP id j8-20020a056870168800b001fb075b99a8mr6143333oae.87.1701682559975; Mon, 04 Dec 2023 01:35:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701682559; cv=none; d=google.com; s=arc-20160816; b=tG7GG6jiOu7sAAh3cNvp6wov/a2XAnSETTsAQAY3yMrbqTJYSS9zdtvRI2R4FOoCEi VQMXl16Wjpq62INrEeDmzseArojYu4OE+ApjWY+V4RrhgTJLGuP/0Itwony7WGfglLJX A5iA2ygI2wz0arOWG4XlBaWSLpDeVBdXUMk7gb3wArhPn23+7tozAO0dZ5zN7tcTsTtA LmtNzOEnABehShaaKh4wUKX+JqZJRgRiCgtiSiBlvtqZdAqX/C1cmF6iUAvQnTK/Zkp3 ZZuxQfa65RcBxbE6ay+ZMyAfwPt28xe0cFKulZcX91dfLXoA/3zIT3p0/oCurf3AsJj0 4J4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=bI9Av4U/SVdm3nbgC/vm7JEvEONt6G/9k0MCILqgaHw=; fh=fw6biwzn34ngIUS3OuPB+D+TvAzoz1YwnvitHxA+Jyw=; b=PzothjeP7idRb7ixMy8GT5l+uJTlLPtPCeBRD+QTpgYjRXtiYMgr+xabfEWdB90OBM XPVchlj9kADUjhloWXA0uOG2n7tnLcNUoQb5pM82TnDS/u+nYl7hAJUODXnjx+JuL56V EOSfpXuhSgxhtbKnzH74pMQ/Wv+IhnFrBNUI83q8UCYJbWscybeDjedG+R3CdNG8tEMR hp34LFkvw0/TdzMQLjKofmRM7Lv5plgPxD8l29CybVC5g9Y7UxT8MoMZswgxJQQTUfaY 7PuXtaIGnuUE5OakCNJuI7NKZgFdDoi0OjBYEPDMK2mx7D0dpD95SkEas8gdmOt6us1H LRWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=h83xtGQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id g10-20020a656cca000000b005bd85b32495si7880119pgw.685.2023.12.04.01.35.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20230601.gappssmtp.com header.s=20230601 header.b=h83xtGQv; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id BF68F807D924; Mon, 4 Dec 2023 01:35:34 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234834AbjLDJfN (ORCPT + 99 others); Mon, 4 Dec 2023 04:35:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40268 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234804AbjLDJfK (ORCPT ); Mon, 4 Dec 2023 04:35:10 -0500 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C7347102 for ; Mon, 4 Dec 2023 01:35:13 -0800 (PST) Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-3333fbbeab9so1274968f8f.2 for ; Mon, 04 Dec 2023 01:35:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20230601.gappssmtp.com; s=20230601; t=1701682512; x=1702287312; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bI9Av4U/SVdm3nbgC/vm7JEvEONt6G/9k0MCILqgaHw=; b=h83xtGQvBmHn3RyU8j9D/9/H+d1CQ9WEs3UAbKrLTFu5Ad5zc2pfD06kOjfKwNWEjs pVHdOvAo1u4NGyRoA8xY88aqF+Q+X5Unc8/+qxODmkVEk/VHMPIPB18RXdRMmlqcbUh4 9L9UDL5y1eGb67DB3rFQzfGEF3LB6vGlqW2yuh33bPcRcpCfmakWTMWv0224AzqyXAzN SXWscdwIwT/KVxaXX6ySPuhWv3Gwf+YomYX94bNSyw9hr1sUto0qV3tdhNqxTN8Zl1Nc rpqxSRrCeA08RWQ6Z4/iatW1Bm4UnK22IgksDs9CYU2H6yGFlcP1Acxu4ifaT9EVyonl kBRw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701682512; x=1702287312; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bI9Av4U/SVdm3nbgC/vm7JEvEONt6G/9k0MCILqgaHw=; b=E5k89wUW9D/JAVG0aKtr7ZtL+UD5FRnqrrAqF+lbycXlGQu5n2HGOgo7BaGVSIO0cH GoUCgUW+NL4AVEmOiLbKVeLrdozIGjfNZE0PXWoPj9j08z6fB4TY9aZMMNYmXQbmkobr 4CswLeUxGNqE6y8OBJ/yyvK3qZLh1Jxl9WauWGzFpbjzNht2uZWR1lJeeAdDY9It85W/ EUtz1aAjbnfo66yhYoRm4ATBykZcoQKzaHwz+HQZre9pxlUBozCB3AR6g9saAtQ/7XR1 57a7j4K01zxUd9mVd5kmyXAsFvlfCK+rdvb6GDCnpQbQ24oSOvaXigKmHDoD3rao7/UY dTSA== X-Gm-Message-State: AOJu0YynwdnV0i2dWB2XH4nY04gjZpuZFDgqGaMeoW0NB9iDuZHSIzgv KywGyhcL4W3u3RcRoKnmnJxGmg== X-Received: by 2002:a05:600c:1912:b0:40b:5e21:e263 with SMTP id j18-20020a05600c191200b0040b5e21e263mr2205541wmq.80.1701682512138; Mon, 04 Dec 2023 01:35:12 -0800 (PST) Received: from brgl-uxlite.home ([2a01:cb1d:334:ac00:4cb1:229e:8c33:122a]) by smtp.gmail.com with ESMTPSA id fs16-20020a05600c3f9000b0040b48690c49sm14266219wmb.6.2023.12.04.01.35.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 01:35:11 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH v3 00/10] gpio/pinctrl: replace gpiochip_is_requested() with a safer interface Date: Mon, 4 Dec 2023 10:34:59 +0100 Message-Id: <20231204093509.19225-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Mon, 04 Dec 2023 01:35:34 -0800 (PST) From: Bartosz Golaszewski While reworking the locking in GPIOLIB I realized that locking the descriptor with users still calling gpiochip_is_requested() will still be buggy as it returns a pointer to a string that can be freed whenever the descriptor is released. Let's provide a safer alternative in the form of a function that returns a copy of the label. Use it in all drivers and remove gpiochip_is_requested(). I plan to provide this series in an immutable branch for the pinctrl and baytrail trees to pull. v2 -> v3: - rename a local variable cpy -> copy - use unsigned int to loop over GPIO lines - use an unscoped guard in patch 10/10 instead of the scoped variant v1 -> v2: - use DEFINE_CLASS() to register a destructor for making sure that the duplicated label doesn't leak out of the for_each loops even with break; Bartosz Golaszewski (10): gpiolib: provide gpiochip_dup_line_label() gpio: wm831x: use gpiochip_dup_line_label() gpio: wm8994: use gpiochip_dup_line_label() gpio: stmpe: use gpiochip_dup_line_label() pinctrl: abx500: use gpiochip_dup_line_label() pinctrl: nomadik: use gpiochip_dup_line_label() pinctrl: baytrail: use gpiochip_dup_line_label() pinctrl: sppctl: use gpiochip_dup_line_label() gpiolib: use gpiochip_dup_line_label() in for_each helpers gpiolib: remove gpiochip_is_requested() drivers/gpio/gpio-stmpe.c | 6 +++- drivers/gpio/gpio-wm831x.c | 14 +++++--- drivers/gpio/gpio-wm8994.c | 13 +++++--- drivers/gpio/gpiolib.c | 35 ++++++++++++-------- drivers/pinctrl/intel/pinctrl-baytrail.c | 11 ++++--- drivers/pinctrl/nomadik/pinctrl-abx500.c | 9 ++++-- drivers/pinctrl/nomadik/pinctrl-nomadik.c | 6 +++- drivers/pinctrl/sunplus/sppctl.c | 10 +++--- include/linux/gpio/driver.h | 39 +++++++++++++++++------ 9 files changed, 96 insertions(+), 47 deletions(-) -- 2.40.1