Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8988ybl; Tue, 7 Jan 2020 01:02:15 -0800 (PST) X-Google-Smtp-Source: APXvYqxtF4F0k/Jnz057dVjqhirPn2/gQrJz2k8R5n5C6LTOfwk59XZzzDrQeFwtAZaWw9A3aJRn X-Received: by 2002:a9d:7cd0:: with SMTP id r16mr125497555otn.50.1578387735625; Tue, 07 Jan 2020 01:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578387735; cv=none; d=google.com; s=arc-20160816; b=d9OwsV0oWJwc89V1yS5ydshOMt+pVhexmtrFrw1RA4Yk9JWmxG5Gqt3rrLqKowjKgH khReEuo3iYHjwvpp4poKXtIie3CEUzwhP+JXbmG1EMFr1oUmBl/bgLKF+iSZo9MkXOhb oQxONk1Fi75SLd/JLZYf+kjkWPdFAx87AoWxpltqP6dm8DCeen0LF5pmDXCMLbKEinPP iKLss6x/44fDPirkMQALf6MRHqXI7jAuYanY1n6Wq3tVm2BhZwa5St/sMWQeSRMuOTow uuYpEOYcOZfk4no4ZtJL8w8NE6NLMjyjZGGrnuYuC8b90D8YVR5dtjUxluEUgPnP/7mi 0tfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=qcYz+S37e6lohC/PrwT9exdPec8JcjwTa/J8RhkOk3Y=; b=Op7NFyDm6HqC1NqGfOeO9smuOF0EoHP/paNgmtM9vDyC0X+nvmdceqQlMyVxg/owgM 3WC1msOhSfl/zR+oRyQxFgo7vEW60ZyhAlBNYb7Z2QB28sIHBYaVTQAVATuUq9dgPc7L WWW8KptD8AP3ShJeH5n8aYdofZ6uQv79O2UXiAC94LoLTK+Fh32rAxYezmTjv1LBJqXJ ZR/dWYR62GH4xVpfmcYK0eHM7hu+ok4+HfcXPwkd2Q/p3Q2o5tGwRswADlwyoJ7xgCdB yrFl0HUrbqqusxzLuMhZpG65IwT0aCXPk6PkHWzKzDd6jcviVAprlEgI+WfuUb4mkG3x ZKww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Co0IXaiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b10si38020917otp.124.2020.01.07.01.02.02; Tue, 07 Jan 2020 01:02:15 -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=@linaro.org header.s=google header.b=Co0IXaiH; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727664AbgAGI7f (ORCPT + 99 others); Tue, 7 Jan 2020 03:59:35 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:35230 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726937AbgAGI7f (ORCPT ); Tue, 7 Jan 2020 03:59:35 -0500 Received: by mail-lj1-f196.google.com with SMTP id j1so46476461lja.2 for ; Tue, 07 Jan 2020 00:59:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=qcYz+S37e6lohC/PrwT9exdPec8JcjwTa/J8RhkOk3Y=; b=Co0IXaiH/+kIDbiPhYQnpNffs6+jp1pyoZ09ElFeN6AOYIbJXEvar943+qbxVK8eVO Ac10A0XtFpcY4904o9UkXWZB/k+R86TnE4uP+o5HbMfmc50EmTA2/8tZqnPU1lY/VRSj +Nq15vL0MeA0WA49I12NeF0uyPfHUDNEhIrdQZ9lmHT+D7Sy1Vo0QQOSovHCVTLEE39m bdqTdDzIdSDP4slKvcGQOaxOZP4WKGC+TVyMuChd+blxaubwKrE/mX4s5+EF9SY8Oekd 0KJ/KSnHv8WYVZWsRhuUr84Amq/wNlLqgaS2VGI13QneOizWgYF/PRXyI3z+9jo+/ZqH wQFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=qcYz+S37e6lohC/PrwT9exdPec8JcjwTa/J8RhkOk3Y=; b=OD7ZyANpefjJm1zPcheQXaNZNf/rfNWUlKRdzIBYpPXC9+OFV71yLtyvZrI+x9x71y vZ+1Q3ayb4HtbA6tSgl0bUfZefzB4+NIXODtDMzY5vfBvpPv8p53/nK1509+7GsR4pSF c0cICP+A8QqgpVELpZ5e6t0ejCPJ7aNDIc6a5RVg5Zs1/5WBBlcsm+em5Z8Tm8zoMtqG wBUW903k5cncmtj0ik89BaYXf1hIankzrcoX7ks2adQ22Ty1WX6QXkmi5oMuU6r46PHu EOg6pF03aSaP+DgVzek8D7wnr9Bnp0AHz5XQYs3rYbSwtYyGKCoQkOdr3t/57iCSa/id JoVQ== X-Gm-Message-State: APjAAAU6V0LYdF9qbadMTUe9g3qWL9xyyT2zEZedTepTCRhgUIk4GqGd eR5sYnNORFIHQyWsMEtcrbIHqeHGyEhPpX2fWQBo2g== X-Received: by 2002:a2e:844e:: with SMTP id u14mr63300233ljh.183.1578387573393; Tue, 07 Jan 2020 00:59:33 -0800 (PST) MIME-Version: 1.0 References: <20191219131459.18640-1-baijiaju1990@gmail.com> In-Reply-To: <20191219131459.18640-1-baijiaju1990@gmail.com> From: Linus Walleij Date: Tue, 7 Jan 2020 09:59:22 +0100 Message-ID: Subject: Re: [PATCH 1/2 v2] gpio: gpio-grgpio: fix possible sleep-in-atomic-context bugs in grgpio_remove() To: Jia-Ju Bai Cc: Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 19, 2019 at 2:15 PM Jia-Ju Bai wrote: > drivers/gpio/gpiolib-sysfs.c, 796: > mutex_lock in gpiochip_sysfs_unregister > drivers/gpio/gpiolib.c, 1455: > gpiochip_sysfs_unregister in gpiochip_remove > drivers/gpio/gpio-grgpio.c, 460: > gpiochip_remove in grgpio_remove > drivers/gpio/gpio-grgpio.c, 449: > _raw_spin_lock_irqsave in grgpio_remove > > kernel/irq/irqdomain.c, 243: > mutex_lock in irq_domain_remove > drivers/gpio/gpio-grgpio.c, 463: > irq_domain_remove in grgpio_remove > drivers/gpio/gpio-grgpio.c, 449: > _raw_spin_lock_irqsave in grgpio_remove > > mutex_lock() can sleep at runtime. > > To fix these bugs, the lock is dropped in grgpio_remove(), because there > is no need for locking in remove() callbacks. > > These bugs are found by a static analysis tool STCheck written by > myself. > > Signed-off-by: Jia-Ju Bai > --- > v2: > * Drop the lock instead of moving the calls to lock functions. > Thank Bartosz for good advice. Looks good to me, patch applied! Yours, Linus Walleij