Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2238017ybv; Mon, 24 Feb 2020 01:42:29 -0800 (PST) X-Google-Smtp-Source: APXvYqya41tC8ISH2Aiu2rcTPqhzBYWsQXanWbiWLxcf8/6n6yHPIXK8GAxMakDtEoPuLcF1D0m3 X-Received: by 2002:a9d:395:: with SMTP id f21mr39562441otf.67.1582537349706; Mon, 24 Feb 2020 01:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582537349; cv=none; d=google.com; s=arc-20160816; b=F4/PblCrP5PI66HhpnocCEGCOzztsQ0+oicCKnmQAaLE+IqnDMrOK+i487nQKieVcn 6k0oFx04dm7etLflNjymwrU502gYxjtq+jNtb/hQG5AqCRNee+jkRJ95F0zizVJIUdkx pHvOONgGOcT37RosRyoFPIi4BKpIKrzb8r4LfodXvzyJDMxXKg7u2Q6I57bxXsVyboYv iTm/R6qMMM63AVcfrj0wdgimDz2NI9AXU77iq+cI/x8UIeVLnWIkQdidXM/2rvwmsgMq ezPcLNAHCrEnvzhwVg/hoDWhGlsG2MhBev7aJHmlLLGWh8iRPXznARxGYM02GWkV22XU l0Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=BDw9QNweqb8Crta/jUlU1isRq0T1j9Nt5ppyUp7U7FY=; b=bcISGvFrvXy+860Tdh7KYTWrdOZSFhNSqwp4fsV/axlwvWCeJyrRWhs9919SEk2fC+ BUIJGoIC8lhg6IicALPOLuJete2c17ezHpVZvwOhk//1I4svOLB56fC7zR04ycltNVYC 67G0nThSn8RaNDceGDefQvHJhIKA5DKGL7jo51pbRLo/quvBKzLy0DwbVV3k0S+KnYHv tsC2IWEDu+/xoOhdkmCZl9+BAFbmPUpsN7E2Hbr3dtJedwBuu3/P0GLsw3f72WaG18SZ 5PS/hMyqazmZ86Sr88+EGh7YSH2JM6v3ayz9J+C43EItJaw9npPHAFh4pQBBJWhHGx/C dzWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=L26uxfUs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 105si795379otd.58.2020.02.24.01.42.15; Mon, 24 Feb 2020 01:42:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=L26uxfUs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727242AbgBXJmD (ORCPT + 99 others); Mon, 24 Feb 2020 04:42:03 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:36152 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726673AbgBXJmD (ORCPT ); Mon, 24 Feb 2020 04:42:03 -0500 Received: by mail-wr1-f67.google.com with SMTP id z3so9537328wru.3 for ; Mon, 24 Feb 2020 01:42:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BDw9QNweqb8Crta/jUlU1isRq0T1j9Nt5ppyUp7U7FY=; b=L26uxfUsLo4EeQiOs+5bVkIce/bMLQNW5Vtw9VHZW2aU9Vao8LzNmUsFPwX8BezftQ MMSh8Pc7lHpx1HXSj1aAWjFqHy3jmYdK3S5UUW/c12PDui27zl5Uhk17ghpBhDpJoDb4 LfDSVZ9mLJUJJiedxP7TKYGWJtTm1X7M1GRk0AAyWkGXqFnfnI6NqqT+m0Sn4FuQtIy0 qH+smPMth3Wue1/bleFMlKbWtRZCWU1xN661hKylmYwBePU49c4A92W6oDdzT7VBlvqB ridJzWCbHOB3sJY+ZtO89r8gjhzjJz/MlJrqXFbdk1wTALGsy7i7sPMQzfZFF8QSLK4P Cpyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=BDw9QNweqb8Crta/jUlU1isRq0T1j9Nt5ppyUp7U7FY=; b=iKxcZtA2oFGZw74yeceSBLXRD8nfu1W0rSjhkhn/Ef2p9Lsk6O7UCnSmUsXWn1KgGs xDxr3Rjw9h5qGBR3gS/DP3g8USa0vc7HHUMP0KsTdzvbIlr0OXzXYaBSU6eVufvwm+pD g2QuAlfolUiAq8ovFW2zRRpmfWdsWlExm1xeArmiLBltEVsmG6d/im2xh/JYmzoPPvx4 m8axdTJcHWmVEpZlsfn5X13gS7EpdWg00WhUoaDJ24kfB7mAjpAJ0J8R83pDh6JsxVlb oQunzLYxg18PG8qgHvgao2T55Y/WyG4BJZh0VO8ievt94n8wgYrcK8GDJoQCuKh5gb6I toYQ== X-Gm-Message-State: APjAAAUEvU//WqWhOSY9pzz7PZ2OsP2hTWLCA6FArMhdcfwwIsxRQpxJ UWgQ06/EF1wK377eUiyA4uDbFA== X-Received: by 2002:a5d:5044:: with SMTP id h4mr62492872wrt.4.1582537322303; Mon, 24 Feb 2020 01:42:02 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id t10sm16920730wmi.40.2020.02.24.01.42.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Feb 2020 01:42:01 -0800 (PST) From: Bartosz Golaszewski To: Linus Walleij , Srinivas Kandagatla , Khouloud Touil , Geert Uytterhoeven Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski Subject: [PATCH 0/3] gpiolib: add reference counting to GPIO descriptors Date: Mon, 24 Feb 2020 10:41:55 +0100 Message-Id: <20200224094158.28761-1-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski This was: nvmem/gpio: fix resource management. These are the remaining patches from the series aimed at fixing resource management problems in nvmem. The first one adds a new descriptor validation macro. The second uses kref to add reference counting to GPIO descriptors. The last one fixes a potential use-after-free problem in nvmem. The last change should actually go into v5.6 but it depends on a new feature. I'm not sure how to go about applying this. Changes in patch 2/3 since the last submission: - add a stub for when GPIOLIB is not selected - use might_sleep() in gpiod_put() as we may not necessarily call gpiod_free() every time now (where it would have been called normally) depending on the reference count Bartosz Golaszewski (3): gpiolib: provide VALIDATE_DESC_PTR() macro gpiolib: use kref in gpio_desc nvmem: increase the reference count of a gpio passed over config drivers/gpio/gpiolib.c | 48 ++++++++++++++++++++++++++++++++--- drivers/gpio/gpiolib.h | 1 + drivers/nvmem/core.c | 2 +- include/linux/gpio/consumer.h | 9 +++++++ 4 files changed, 55 insertions(+), 5 deletions(-) -- 2.25.0