Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp4362773ima; Mon, 4 Feb 2019 15:15:20 -0800 (PST) X-Google-Smtp-Source: AHgI3IYM4ivUMaFFexQ47wvQgU7PdsG8+4rb/izjNCgHeF0wVInpHA3eyDdNU5TddtQaIH/YIWsa X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr1977143plo.50.1549322120674; Mon, 04 Feb 2019 15:15:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549322120; cv=none; d=google.com; s=arc-20160816; b=hdWSOhfJxYQB0O5tHYazErtcBFvbXijqL1hDnRoMXxzKMEb6nb0zYn8HsIsuSfox0l HesTE/yZ/olcRxEeLBIfZgleDEEYZ5KDZoZiZUo+ubZPjlxftDyoko6AMxnhjpUKqZ0B pUE0NX9nRjpXcLYTOjbTZXvZBj1B9cMnpyxIyX0Rhi9d873OaA5CG6j3f3BqruN25ITl gBUdzIV6Fm3PlPO5TetH/ufIj0hmal+oGAIf1YmkH5z7R426Iq41dQOr06QEFrG208VE 80w4dwACOmPK2jFKaC1xXxgCbP50St4mhr4laBwxHoUfqy8jOMKiRuagvjMWEYZDSvf8 i7mQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=no1CQYYZfwWp6SvKdMZoJZxgBc8oWBoFZAog9MiYL2M=; b=AzA5FFbLEGCycO81eD5tDWwJXw4y7H6okomlDNJKBU4S/ZN/xYyO2KxymzFrn+e43t 2nO3b3gCmpg9w/OsPNKlNQnHfJeTnc1TJuNi79vhsbF7WT9xCNg6uaxgpoKyn0+8609G P1UobwBsKKUx0euTXY4hGsedrfP4yLnjlCE/TOnIoDmnGGz8OHqh7CfsmO/nU2WGzcFX 3WEQLnRE7pSV6IvARpV7iDaZ76C4bAPYm7jxOaY1QHaW7AsnHgl20FYBr1yZSqjrc1lh rnWic4+jsy5RLHgLAd6B8SpFD0be6mn1X7rnQirVDH0LPkCuIs4S2opyQs2Nj08xQ4mo u3BA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=ZQA2N5QC; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g98si1439937plb.99.2019.02.04.15.15.05; Mon, 04 Feb 2019 15:15:20 -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=@gmail.com header.s=20161025 header.b=ZQA2N5QC; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727273AbfBDWKN (ORCPT + 99 others); Mon, 4 Feb 2019 17:10:13 -0500 Received: from mail-it1-f196.google.com ([209.85.166.196]:32971 "EHLO mail-it1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726909AbfBDWKA (ORCPT ); Mon, 4 Feb 2019 17:10:00 -0500 Received: by mail-it1-f196.google.com with SMTP id m8so12783982itk.0 for ; Mon, 04 Feb 2019 14:09:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=no1CQYYZfwWp6SvKdMZoJZxgBc8oWBoFZAog9MiYL2M=; b=ZQA2N5QCanNKCfayOHnpV8NXqP8kqGDUUlYcjIo+L1oCvlSxXyBPhDwGsDAndccR2o 7kvq1IZony2+5RTCCrD0DNwrXkeLSK5wgozaLzyfayknqedcOQHQjoJrld5tD+QEFh/x WZ8sc/Mz8TSyJfUShvXLBtRffzWLSFj5lCvVVubONbAzbWCzkHEoe/AWBTo7z9kGlwH/ aPqQQs63NuMNijJbVcrAmCJPeD7AXyyeduBheImjdTjZ/LIkIEFomHC5VkwcKsoXcILC 2O6DC28nPnEZc7I8huMVHMAJheYmMYvyVLv+eBHV0BI+Qu8k5n6hs5JTCqiVoe49YtbT wc4A== 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:in-reply-to :references; bh=no1CQYYZfwWp6SvKdMZoJZxgBc8oWBoFZAog9MiYL2M=; b=U8g7PMG8SEC5EcaTgGjp2gDuKUaq2l2E8Lhcacw2Lawn3E83Ggwy/+Q3Tdj9cWa9QK 1ZjWx4pCVnP0hvs9w+OIoA+xfYreGxgVI3HVfddsFGAWjWjmKQ1kiTlx2sh+CSdX+4eR +urj57JdkXUMJRNbkRxVcu2P6VVJrpTrJByLYF9M70bwgs3Y7HbYX6LAAb6vwaBjQjch YuAb1h1N/9XYYng4vwgV9q1cZRiv0fr04kwlYIFFnYYcgAhj0o4KPEK5x7AECviq3XXW sUNB9joBOdTAO4S2d6L2msjG/4KNqV6UoOQ0uGxpBuOJDdN7JhXEqARldXU2g4RYsML5 l6Lw== X-Gm-Message-State: AHQUAuZTqDAHGB21/gzSc9+5BLQ8FvWwPKFrDyE4aNWT8nF51GxYZE95 skykfwlTwvX3SygU6lKeybwzW3Yn X-Received: by 2002:a02:a589:: with SMTP id b9mr910418jam.113.1549318199312; Mon, 04 Feb 2019 14:09:59 -0800 (PST) Received: from svens-asus.arcx.com ([184.94.50.30]) by smtp.gmail.com with ESMTPSA id z1sm531602ioi.77.2019.02.04.14.09.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Feb 2019 14:09:58 -0800 (PST) From: Sven Van Asbroeck X-Google-Original-From: Sven Van Asbroeck To: Tejun Heo Cc: Lai Jiangshan , linux-kernel@vger.kernel.org, Sebastian Reichel , Dmitry Torokhov , Kees Cook Subject: [RFC v1 3/3] cap11xx: fix potential user-after-free on module unload Date: Mon, 4 Feb 2019 17:09:52 -0500 Message-Id: <20190204220952.30761-4-TheSven73@googlemail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190204220952.30761-1-TheSven73@googlemail.com> References: <20190204220952.30761-1-TheSven73@googlemail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The work which is scheduled by led_classdev->brightness_set() is potentially left pending or running until after the driver module is unloaded. Fix by using resource-controlled version of INIT_WORK(). Signed-off-by: Sven Van Asbroeck --- drivers/input/keyboard/cap11xx.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/input/keyboard/cap11xx.c b/drivers/input/keyboard/cap11xx.c index 312916f99597..a92dd8ee9ed7 100644 --- a/drivers/input/keyboard/cap11xx.c +++ b/drivers/input/keyboard/cap11xx.c @@ -312,7 +312,11 @@ static int cap11xx_init_leds(struct device *dev, led->reg = reg; led->priv = priv; - INIT_WORK(&led->work, cap11xx_led_work); + error = devm_init_work(dev, &led->work, cap11xx_led_work); + if (error) { + of_node_put(child); + return error; + } error = devm_led_classdev_register(dev, &led->cdev); if (error) { -- 2.17.1