Received: by 10.192.165.156 with SMTP id m28csp752220imm; Thu, 19 Apr 2018 07:02:59 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+mvxxxxdPCBwQajiKKZp7XCWsmtG5s2bscwFUqfkPp1sulzF78CVsw1JrYMontpqyS5jcP X-Received: by 10.98.204.220 with SMTP id j89mr5656998pfk.182.1524146579604; Thu, 19 Apr 2018 07:02:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524146579; cv=none; d=google.com; s=arc-20160816; b=mWRw0pf9WOkA21kfUwLj6+p1uHhj5qWlP1Jp/s7cyUSU2oUc9LtLRnWVJZ+z3U/Mg6 qMGpKUaClHddc4VQymK/04tR09HNmgcaiOwHTrmRAK9vqMG/keeazvn/GpVxuPwomvH0 3eoAlQMMSWkB0d5vm9vmxAcPephyRcm4vSrGqXTuoAPm8rUv2wJQhYFgboHl8WluGucM RiVrCHiZbgFQUvEC2bCz22Kv07B4MZATLdt1TEqL4X0S7HEB55umBNN6fqW9i1zCFGnX MmWyHdIRHSo4/sjBxSvOhFsk9L7UD9+Ao5ugSBt4keZoHh6So0EZGGuFQR2EN7j36SIL v0vw== 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:cc:to:subject :message-id:date:from:references:in-reply-to:mime-version :dkim-signature:arc-authentication-results; bh=1ryVM8jljH5YKl93xVt8G+d145zadGSrUVHzGv8yaDM=; b=Qf9BEys6q8OtgHZmLCU8vw9qt7bCwC7CwEGXHJ3uyFKGYL950viwcw+RKU0+hS0osM HT80kuF+ndkRs3cBRNRTpnO71f2p4seXisAr0TsRaOXn6qHIRBwQGj1tBMwAU0uSJzhf Wc0DqP2gO5mQJgjoEWhJwlKdMqyz7gK5glgJw9P030F48j/glzwo/AydGQkosXphG1Rh ozK9DneJlIx8AUx2JIIz6GyFlKieogyUKhunsAXG46+uZrZ4TMCdc+5NYgiAsnGxM/NG PvIgNxuVCkRasu0nSwelWzktOkPrA1t/p4RE+Wrb8LuYXp+Cc/EhGqFVKC9GUcsh+5AO t1Iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=f/K3dske; 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 d68si2995149pgc.137.2018.04.19.07.02.44; Thu, 19 Apr 2018 07:02:59 -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=f/K3dske; 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 S1752283AbeDSOBV (ORCPT + 99 others); Thu, 19 Apr 2018 10:01:21 -0400 Received: from mail-pl0-f66.google.com ([209.85.160.66]:36430 "EHLO mail-pl0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750858AbeDSOBT (ORCPT ); Thu, 19 Apr 2018 10:01:19 -0400 Received: by mail-pl0-f66.google.com with SMTP id m7-v6so3310286plt.3; Thu, 19 Apr 2018 07:01:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=1ryVM8jljH5YKl93xVt8G+d145zadGSrUVHzGv8yaDM=; b=f/K3dskeq3/uQTuq6th5ZEZeCwahKfqdKQgpkZCcNN2VoVBtBrb8XM6pYv7r9+y/v8 kN5li7bB7J0yvCl0ZwSHvxZlyqPlTGl+MV4v4O+p4mI+D7D8guqo0DjXVM30GxUIZZ+y F5DOcYWB79X00QSbc8gsK8pOR/w/inrXHuIvgzKFpjKg5E6XjqvMrNoTXDLjftWxtqrX PBiPRlk6GNeHzaXrDPHlpxpmkgkAALW/18CoKb9DSNxTrCMHI/biFm3jvtjhwNijNK+H 047Ki/UefyyhhkYMTRX3iivIkwYQD5IKk6iJ1eQL2QFOUABG9bMaDC3oSMYe4i9qpbnB Fb2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=1ryVM8jljH5YKl93xVt8G+d145zadGSrUVHzGv8yaDM=; b=qjBbcgjUQSrdDegaZq2FbZBiKYquVJ1boVa4HS1roUGx6sSpqy+DKEwwFiJEq1oOlx 91DNcZi7AqsnFis7omPgkTIK4wkngzL3phRilUcL7ZVrZEyQEfZf2AUOGzPPW8/qEaUf QrL/Wkaulg9qSDY1kzpQaklnS3h6TNJm3wuaU81baxcJzw3t07AsluDxppF7k/Zu3ts2 2uTxp9mkyajQXtwEMX45CMO4t2mxMO0l2TXm4Sx9xXmMz4azl7yzdiO5B2618SfkGW6X 4iMBooHLNWruqd/dBjTQoCPIXz03+9kaEqrPe1tvPseYxzK6+Vpgqp5vhWp1/3M3W/Gx r6Mg== X-Gm-Message-State: ALQs6tDPuuf6mXmctFT2KPQBspE15SKJxp6ub3gEyZQf5ydlT9tec/xK QZAC+7edm1kCW7XL2K0onfpZ3JvSULxYCdWEu2Sr4bR8 X-Received: by 2002:a17:902:7709:: with SMTP id n9-v6mr6366760pll.385.1524146478582; Thu, 19 Apr 2018 07:01:18 -0700 (PDT) MIME-Version: 1.0 Received: by 10.236.138.1 with HTTP; Thu, 19 Apr 2018 06:59:43 -0700 (PDT) In-Reply-To: <20180407155006.GA11256@fury> References: <20180407053729.5434-1-jprvita@endlessm.com> <20180407155006.GA11256@fury> From: =?UTF-8?Q?Jo=C3=A3o_Paulo_Rechi_Vita?= Date: Thu, 19 Apr 2018 06:59:43 -0700 Message-ID: Subject: Re: [PATCH] platform/x86: asus-wireless: Fix NULL pointer dereference To: Darren Hart Cc: Corentin Chary , Andy Shevchenko , Platform Driver , acpi4asus-user , LKML , linux@endlessm.com, Dun Hum , =?UTF-8?Q?Jo=C3=A3o_Paulo_Rechi_Vita?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Apr 7, 2018 at 8:50 AM, Darren Hart wrote: > On Fri, Apr 06, 2018 at 10:37:29PM -0700, Jo=C3=A3o Paulo Rechi Vita wrot= e: >> 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. >> > > Thanks Jo=C3=A3o Paulo, > ... > >> Unregistering the led device on the remove callback before destroying th= e >> workqueue avoids this problem. >> >> https://bugzilla.kernel.org/show_bug.cgi?id=3D196097 >> >> Reported-by: Dun Hum >> Signed-off-by: Jo=C3=A3o 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 =3D acpi_driver_data(adev); >> >> + devm_led_classdev_unregister(&adev->dev, &data->led); >> if (data->wq) >> destroy_workqueue(data->wq); >> return 0; > > asus_wireless_add only calls devm_led_classdev_register() iff the workque= ue is > successfully created. It seems like it would make sense to move the > devm_led_classdev_unregister() call within the 'if (data->wq)' condition = block. > I agree. I didn't do it this way initially as I believe the call to devm_led_classdev_unregister() would be harmless in any case, but it indeed best to avoid it if we can. > This should also cc stable. > Adding to v2. -- Jo=C3=A3o Paulo Rechi Vita http://about.me/jprvita