Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1110473imm; Wed, 1 Aug 2018 10:20:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpfj957YrKXmEFQAnTGx9+GYrpyNqTqBhNTgKpesdtOwyjDxy1ipn4AteLzcMhGpQrocc0/l X-Received: by 2002:aa7:88d3:: with SMTP id p19-v6mr27720244pfo.160.1533144053330; Wed, 01 Aug 2018 10:20:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533144053; cv=none; d=google.com; s=arc-20160816; b=X8dAztbff3nunHT2yoGnVWKA7brH9fQXTaiYo65b55EK/yMSI3PtVZ1i81nn7VD5de cTycpdYvrzJaEzbHDRzh93EatfjXMQo/+oudRA3SYxGOVqdoRVGJXX10ITuVVgHoTaFb aFwW1T+tc5CB0hCU7roTpyybWApCMLOymYzBrSOmTtLCOkrEFXElcFkPtJpZN01rZWni rsiXbv9tLpGY4LozdVYiiDiNxcbcq5pZsDyoRh4C3smue0tb8bmcZ8/YkPF+qDFRrBhE hMrYZoOvMAdigSrCOGAXliJi2vnCAY2K40ZHZ0YKD1z1lMCzZvYfEo8YehYUk84ADCKg /47A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=KAs0V+EFganIqK4lcZWr4aMQtgTMR3lY0RmE9l+Q72M=; b=00SDmNYy7+dfTFzDA4wAgYR0W2enAnmNYqML6VVMWaq7114mmVTfdclWeaUAklcVTQ cZnF406562nqxW3Ktfagc0UlcFtCEMFFCxQmH43IxEekZcHQpcxWYvF/mGhsmfkbXLw8 kQNachCbhTzmRT02Lj4hRHOF48Ott53pv8Uc5unOlbB55n4SdKtIJ7zC3lf0r740sgCB q1nZzG47VrWZZjzgPnpe4NaEAyMcDngGWO+F3xUSJUpyED8QUGf5euZiC8XMNitwnA1k N/JyL2aQXmRCwJBt9bQ6S7nM58pe1rn8lvAcfE4Kp+5c6woJb/tgT6MU+QhXWig403fC W9jw== ARC-Authentication-Results: i=1; mx.google.com; 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 n6-v6si15561853pla.398.2018.08.01.10.20.38; Wed, 01 Aug 2018 10:20:53 -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; 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 S2404840AbeHATEm (ORCPT + 99 others); Wed, 1 Aug 2018 15:04:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:46564 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2403856AbeHATEk (ORCPT ); Wed, 1 Aug 2018 15:04:40 -0400 Received: from localhost (D57E6652.static.ziggozakelijk.nl [213.126.102.82]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 84944C96; Wed, 1 Aug 2018 17:17:59 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexandre Belloni , Sasha Levin Subject: [PATCH 4.14 124/246] rtc: tps65910: fix possible race condition Date: Wed, 1 Aug 2018 18:50:34 +0200 Message-Id: <20180801165017.660900984@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180801165011.700991984@linuxfoundation.org> References: <20180801165011.700991984@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 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 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alexandre Belloni [ Upstream commit e6000a438e534ee0afd9e83b67f4e23a26dd1067 ] The IRQ is requested before the struct rtc is allocated and registered, but this struct is used in the IRQ handler. This may lead to a NULL pointer dereference. Switch to devm_rtc_allocate_device/rtc_register_device to allocate the rtc before requesting the IRQ. Signed-off-by: Alexandre Belloni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/rtc/rtc-tps65910.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/drivers/rtc/rtc-tps65910.c +++ b/drivers/rtc/rtc-tps65910.c @@ -380,6 +380,10 @@ static int tps65910_rtc_probe(struct pla if (!tps_rtc) return -ENOMEM; + tps_rtc->rtc = devm_rtc_allocate_device(&pdev->dev); + if (IS_ERR(tps_rtc->rtc)) + return PTR_ERR(tps_rtc->rtc); + /* Clear pending interrupts */ ret = regmap_read(tps65910->regmap, TPS65910_RTC_STATUS, &rtc_reg); if (ret < 0) @@ -421,10 +425,10 @@ static int tps65910_rtc_probe(struct pla tps_rtc->irq = irq; device_set_wakeup_capable(&pdev->dev, 1); - tps_rtc->rtc = devm_rtc_device_register(&pdev->dev, pdev->name, - &tps65910_rtc_ops, THIS_MODULE); - if (IS_ERR(tps_rtc->rtc)) { - ret = PTR_ERR(tps_rtc->rtc); + tps_rtc->rtc->ops = &tps65910_rtc_ops; + + ret = rtc_register_device(tps_rtc->rtc); + if (ret) { dev_err(&pdev->dev, "RTC device register: err %d\n", ret); return ret; }