Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3343414ybb; Sun, 22 Mar 2020 22:11:27 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtz6YrMzcLDkm+w5/kVjKrvbZZCoSvj14Tzcb4til3sJZhtHHnKsyPZK3g24wVoBL6Oxc7o X-Received: by 2002:a05:6808:64c:: with SMTP id z12mr5102857oih.146.1584940287291; Sun, 22 Mar 2020 22:11:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584940287; cv=none; d=google.com; s=arc-20160816; b=1CeUDk24BWVy0+g1NlOPKcxH7UVEle44ltHQwvs1eHCPAR17MBfdJPb924r53xu/eQ W4k5ciwJ9Q3e6REgYTPcyb2OOC+OzQ55rFPsksoN8hi70hTXcyf69t+Cl7woarToIz8P k7c1Q8bbmk7JDrm3ct7oZe4wBM2XsYO15deY/PfbA8/uOAxFHekTsAuOI1fsOYeTyqfV h0wb/+vOPs6wSIuF00GvshLziFIrq3ZBX5/x9ErVK2fSqqQmMciuF8J3evsdgL2j3GFM FHVwhc1iTqRS/buN/Nxx3tlunUpfPFT4jVd55boo1ETvTbjpfWEkb788ZoNCTelKWpKI 2NBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dmarc-filter:dkim-signature; bh=YwgqPRzi5A+j0qLDmgYbIu+o6KUyxQt47gBd1J1KNzA=; b=d2ieMfL2WUoBuSDkPs6MXkM64dQaaxjRir+CWdb7R7zXTdAfivtTa01M82VErhjhvo U0NoQeJGlG68rg13D7oXPMiiVjvydqoqXn3rt3Y8AxtAb3An7LEj1EdIFfPbLp/iovrO kZLGo2CbRzguoI9UKBPYx1GkzgIXUSM2m60Mzia5fcC521Qnvlcs2IZ7TbsDlMze3fl9 a0QYpsont8cJzqUPI4q3nAGvgKuML96M4QenAk9Nk7sgd92e2oG+bkkWzb4HjvKcgxMC FZOfOelCtfu9oK9LWBR3HN18Gfy4nxqts7P4punP6CXjWJQE5rKAQ3UFYvLfZapElR4r q9Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=xkZiJxn7; 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 p25si7459363ota.143.2020.03.22.22.11.04; Sun, 22 Mar 2020 22:11:27 -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=fail header.i=@mg.codeaurora.org header.s=smtp header.b=xkZiJxn7; 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 S1725990AbgCWFJY (ORCPT + 99 others); Mon, 23 Mar 2020 01:09:24 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:21269 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725866AbgCWFJY (ORCPT ); Mon, 23 Mar 2020 01:09:24 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1584940163; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=YwgqPRzi5A+j0qLDmgYbIu+o6KUyxQt47gBd1J1KNzA=; b=xkZiJxn7DoFBJzRpIgFFSyIiUBU6PIFojnz6+RQHG/VN9j0JcpPsDc4wk3ngBECEZrPST7sL vcsJuIwrFpfIFKwcjleyNkL09jzplc0+Fa1ottKcl/TjTsEW5hlC9Mrn5Bxe/pKhSnWh0d6u 06BqD4SSyiiOw7alii/tywYG+jI= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e784470.7f5e12e18570-smtp-out-n01; Mon, 23 Mar 2020 05:09:04 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id D2D89C433CB; Mon, 23 Mar 2020 05:09:03 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from neeraju-linux.qualcomm.com (blr-c-bdr-fw-01_GlobalNAT_AllZones-Outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: neeraju) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0B71FC433D2; Mon, 23 Mar 2020 05:08:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0B71FC433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=neeraju@codeaurora.org From: Neeraj Upadhyay To: rjw@rjwysocki.net, pavel@ucw.cz, len.brown@intel.com, gregkh@linuxfoundation.org, swboyd@chromium.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, irgeorgiev@codeaurora.org, linux-arm-msm@vger.kernel.org, Neeraj Upadhyay Subject: [PATCH] PM / wakeup: Skip wakeup_source_sysfs_remove if device is not added Date: Mon, 23 Mar 2020 10:38:51 +0530 Message-Id: <1584940131-1591-1-git-send-email-neeraju@codeaurora.org> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Skip wakeup_source_sysfs_remove(), to fix null pinter access of ws->dev, if wakeup source is unregistered before wakeup class is registered from device_add(). Fixes: 2ca3d1ecb8c4 ("PM / wakeup: Register wakeup class kobj after device is added") Signed-off-by: Neeraj Upadhyay --- drivers/base/power/wakeup.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index 27f3e60..f8f8c0a 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c @@ -241,7 +241,8 @@ void wakeup_source_unregister(struct wakeup_source *ws) { if (ws) { wakeup_source_remove(ws); - wakeup_source_sysfs_remove(ws); + if (ws->dev) + wakeup_source_sysfs_remove(ws); wakeup_source_destroy(ws); } } -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation