Received: by 10.213.65.68 with SMTP id h4csp315720imn; Fri, 6 Apr 2018 22:41:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/q8bfPWSTClNp2adf5kamtF6sK95hJRUspOFkvVwIVJ/kefW+pOZzOiNGTrfzJjb6f0c9R X-Received: by 10.101.98.196 with SMTP id m4mr8135169pgv.329.1523079703880; Fri, 06 Apr 2018 22:41:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523079703; cv=none; d=google.com; s=arc-20160816; b=u1OevM2CHXQBVcTEmkoDqTnn40TlsP94SDv/NRjldq5Vxe3qFDFRdQ0y2YAVGOnqJx qNKHqz1qH7x6y+k1u/KGfUBTmSCamjd37dMM1pN0Zto9+2LnscH3azOhSi4r2coeatB2 NUgKfeE1g9UxED8TCxwEjiT/z7l5C0gMci4UAeYHimrcbchxMOSwvb6bnfv9CVWRcnkZ osdY1Xy/3Pny0zlt9Ug0vs9J1CJZ/POtOL+Dkd82rNtQER6OUPuLuFutZ4RyGBJudT7L IxkfD3UNGAJUwZ9wkEu+x88D8K8kPsAw/6eWSQHej/nt9FaWpuM6F8NVfH+9gx5ibVBz pP4g== 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 :arc-authentication-results; bh=7hLF39qDGRQGzJOzO/HJYR1V/nFz81xEBy0kAoJUyM8=; b=t5EeGrhUDL91/1AtnJYO4hLlvghG4pgJSE49r3JW2CdX6AVATKAWjWB8d0c0M9YTvj bO6ARlgsXq///HiS8304BY5bsDor0ykWUuYKU8CC4mj7LtzPEVXIKPw4XTD6Ap9py9yV N/AYrVGa/c5vWonZTTEsH6mDS92sNjwTVoV1NhqsZLS/ls0iRRBMnegQ47SI4dRTTqJA WYNkMo/ISnZwf0f6qP/zqATWCSK91vqrsVd1ooDawWwnwl9usZVEAl0YEZd+e11bk512 rgycmVpRUl0CgqElHzR5mtLvgyFYMbzKugR56Cx6gUp2SNBvyNjoOu6z3DEVo/ckM1id Ay5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Pxfv4f+n; 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 f89-v6si10143091plf.488.2018.04.06.22.40.55; Fri, 06 Apr 2018 22:41:43 -0700 (PDT) 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=Pxfv4f+n; 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 S1751079AbeDGFhf (ORCPT + 99 others); Sat, 7 Apr 2018 01:37:35 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:40662 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750921AbeDGFhd (ORCPT ); Sat, 7 Apr 2018 01:37:33 -0400 Received: by mail-pl0-f67.google.com with SMTP id x4-v6so1902878pln.7; Fri, 06 Apr 2018 22:37:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=7hLF39qDGRQGzJOzO/HJYR1V/nFz81xEBy0kAoJUyM8=; b=Pxfv4f+nVQSf5Wv9vFv/Ulq0bk1gk7NGpBoz2mBTl0Se+pmqBctGWR0YMHJX9j6duD LTKwBg6MtvPCtCrGq3jFOZiKxc9Zx7nBB9pKrg5zs8LNXn9jbqbFyinX8gbgXccTipOj UIQB5Y6kXOoKdTI0rzAb68QcQYcNWUJiflgn95csVEAJQY6MjTGlByLoU2/rX+Y178zY L9CpiQmry3ddlj/Pbc+geq7Qeb51NVaWTmqtA9hAj9qSPKuvo7TSvNyJLffRbRoxZ0EV fhqDW4VnAGDnyLsgbIwSDbW5XArR1Od9pM9DXN5NzI+ErTWnqHRDskFnziK0mQ3HgfYL D1NA== 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=7hLF39qDGRQGzJOzO/HJYR1V/nFz81xEBy0kAoJUyM8=; b=gUGIfq0n8N39r3Lnz69tU0nfQiH7D3O+FMMD7IN39mkI7f3CeRsFqCA9vcuQfe0YiM Y4H764lApl/DuJVivgqyvlUZ3/S5YYNKGY+hKGHiATDmJQo+QhAlvFCa4AF6fA3JX8ku QyHso7GHz8W15DXqTa6359RpAjlYM1hJQaVxGjPw86NE70O/HLx8yryrguc+86zpKIgd lyfrQ1R5CrRAwV818rOYPpIo+6bajPf/VmS7aWeVbyukdN/Mrsa9k+b9U9muPPZyUBnJ pMfZI9kkj61uPXUWcjRYWk7CPzz82EjQTNUMj8ZQSjeopo1fNKjlX3S9KWTirMUX+Uzy ULZg== X-Gm-Message-State: AElRT7FLoTOUuwT4O4D2KGYrCVm+B0n3jydhnTZX+qD7gSplDUdbF1az 7blsQqKmOxc2rBQ7UIxRHwM= X-Received: by 2002:a17:902:6849:: with SMTP id f9-v6mr30776961pln.139.1523079453057; Fri, 06 Apr 2018 22:37:33 -0700 (PDT) Received: from kiddo.hsd1.wa.comcast.net (c-73-97-192-101.hsd1.wa.comcast.net. [73.97.192.101]) by smtp.gmail.com with ESMTPSA id c64sm23164242pfe.152.2018.04.06.22.37.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 06 Apr 2018 22:37:32 -0700 (PDT) From: "=?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?=" X-Google-Original-From: =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= To: Corentin Chary , Darren Hart , Andy Shevchenko Cc: platform-driver-x86@vger.kernel.org, acpi4asus-user@lists.sourceforge.net, linux-kernel@vger.kernel.org, linux@endlessm.com, Dun Hum , =?UTF-8?q?Jo=C3=A3o=20Paulo=20Rechi=20Vita?= Subject: [PATCH] platform/x86: asus-wireless: Fix NULL pointer dereference Date: Fri, 6 Apr 2018 22:37:29 -0700 Message-Id: <20180407053729.5434-1-jprvita@endlessm.com> X-Mailer: git-send-email 2.16.3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the module is removed the led workqueue is destroyed in the remove callback, before the led device is unregistered from the led subsystem. This leads to a NULL pointer derefence when the led device is unregistered automatically later as part of the module removal cleanup. Bellow is the backtrace showing the problem. BUG: unable to handle kernel NULL pointer dereference at (null) IP: __queue_work+0x8c/0x410 PGD 0 P4D 0 Oops: 0000 [#1] SMP NOPTI Modules linked in: ccm edac_mce_amd kvm_amd kvm irqbypass crct10dif_pclmul crc32_pclmul ghash_clmulni_intel pcbc aesni_intel aes_x86_64 joydev crypto_simd asus_nb_wmi glue_helper uvcvideo snd_hda_codec_conexant snd_hda_codec_generic snd_hda_codec_hdmi snd_hda_intel asus_wmi snd_hda_codec cryptd snd_hda_core sparse_keymap videobuf2_vmalloc arc4 videobuf2_memops snd_hwdep input_leds videobuf2_v4l2 ath9k psmouse videobuf2_core videodev ath9k_common snd_pcm ath9k_hw media fam15h_power ath k10temp snd_timer mac80211 i2c_piix4 r8169 mii mac_hid cfg80211 asus_wireless(-) snd soundcore wmi shpchp 8250_dw ip_tables x_tables amdkfd amd_iommu_v2 amdgpu radeon chash i2c_algo_bit drm_kms_helper syscopyarea serio_raw sysfillrect sysimgblt fb_sys_fops ahci ttm libahci drm video CPU: 3 PID: 2177 Comm: rmmod Not tainted 4.15.0-5-generic #6+dev94.b4287e5bem1-Endless Hardware name: ASUSTeK COMPUTER INC. X555DG/X555DG, BIOS 5.011 05/05/2015 RIP: 0010:__queue_work+0x8c/0x410 RSP: 0018:ffffbe8cc249fcd8 EFLAGS: 00010086 RAX: ffff992ac6810800 RBX: 0000000000000000 RCX: 0000000000000008 RDX: 0000000000000000 RSI: 0000000000000008 RDI: ffff992ac6400e18 RBP: ffffbe8cc249fd18 R08: ffff992ac6400db0 R09: 0000000000000000 R10: 0000000000000040 R11: ffff992ac6400dd8 R12: 0000000000002000 R13: ffff992abd762e00 R14: ffff992abd763e38 R15: 000000000001ebe0 FS: 00007f318203e700(0000) GS:ffff992aced80000(0000) knlGS:0000000000000000 CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033 CR2: 0000000000000000 CR3: 00000001c720e000 CR4: 00000000001406e0 Call Trace: queue_work_on+0x38/0x40 led_state_set+0x2c/0x40 [asus_wireless] led_set_brightness_nopm+0x14/0x40 led_set_brightness+0x37/0x60 led_trigger_set+0xfc/0x1d0 led_classdev_unregister+0x32/0xd0 devm_led_classdev_release+0x11/0x20 release_nodes+0x109/0x1f0 devres_release_all+0x3c/0x50 device_release_driver_internal+0x16d/0x220 driver_detach+0x3f/0x80 bus_remove_driver+0x55/0xd0 driver_unregister+0x2c/0x40 acpi_bus_unregister_driver+0x15/0x20 asus_wireless_driver_exit+0x10/0xb7c [asus_wireless] SyS_delete_module+0x1da/0x2b0 entry_SYSCALL_64_fastpath+0x24/0x87 RIP: 0033:0x7f3181b65fd7 RSP: 002b:00007ffe74bcbe18 EFLAGS: 00000206 ORIG_RAX: 00000000000000b0 RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 00007f3181b65fd7 RDX: 000000000000000a RSI: 0000000000000800 RDI: 0000555ea2559258 RBP: 0000555ea25591f0 R08: 00007ffe74bcad91 R09: 000000000000000a R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000000003 R13: 00007ffe74bcae00 R14: 0000000000000000 R15: 0000555ea25591f0 Code: 01 00 00 02 0f 85 7d 01 00 00 48 63 45 d4 48 c7 c6 00 f4 fa 87 49 8b 9d 08 01 00 00 48 03 1c c6 4c 89 f7 e8 87 fb ff ff 48 85 c0 <48> 8b 3b 0f 84 c5 01 00 00 48 39 f8 0f 84 bc 01 00 00 48 89 c7 RIP: __queue_work+0x8c/0x410 RSP: ffffbe8cc249fcd8 CR2: 0000000000000000 ---[ end trace 7aa4f4a232e9c39c ]--- Unregistering the led device on the remove callback before destroying the workqueue avoids this problem. https://bugzilla.kernel.org/show_bug.cgi?id=196097 Reported-by: Dun Hum Signed-off-by: João Paulo Rechi Vita --- drivers/platform/x86/asus-wireless.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/platform/x86/asus-wireless.c b/drivers/platform/x86/asus-wireless.c index 343e12547660..ecd715c82de5 100644 --- a/drivers/platform/x86/asus-wireless.c +++ b/drivers/platform/x86/asus-wireless.c @@ -181,6 +181,7 @@ static int asus_wireless_remove(struct acpi_device *adev) { struct asus_wireless_data *data = acpi_driver_data(adev); + devm_led_classdev_unregister(&adev->dev, &data->led); if (data->wq) destroy_workqueue(data->wq); return 0; -- 2.16.3