Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3c38799c authored by Mohit Aggarwal's avatar Mohit Aggarwal Committed by Gerrit - the friendly Code Review server
Browse files

rtc: qpnp-rtc: Add NULL pointer checks



In shutdown hook, null pointer check is missing.
So during probe, if RTC H/w is not enabled, rtc
driver data will not be initialized. This patch
adds null pointer checks in shutdown hook.

Change-Id: I1ecdaef8415394c853ce9658ec0da0946f08ad92
CRs-Fixed: 545637
Signed-off-by: default avatarMohit Aggarwal <maggarwa@codeaurora.org>
parent cad6f8bd
Loading
Loading
Loading
Loading
+13 −3
Original line number Original line Diff line number Diff line
/* Copyright (c) 2012-13, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -588,9 +588,19 @@ static void qpnp_rtc_shutdown(struct spmi_device *spmi)
	u8 reg;
	u8 reg;
	int rc;
	int rc;
	unsigned long irq_flags;
	unsigned long irq_flags;
	struct qpnp_rtc *rtc_dd = dev_get_drvdata(&spmi->dev);
	struct qpnp_rtc *rtc_dd;
	bool rtc_alarm_powerup = rtc_dd->rtc_alarm_powerup;
	bool rtc_alarm_powerup;


	if (!spmi) {
		pr_err("qpnp-rtc: spmi device not found\n");
		return;
	}
	rtc_dd = dev_get_drvdata(&spmi->dev);
	if (!rtc_dd) {
		pr_err("qpnp-rtc: rtc driver data not found\n");
		return;
	}
	rtc_alarm_powerup = rtc_dd->rtc_alarm_powerup;
	if (!rtc_alarm_powerup && !poweron_alarm) {
	if (!rtc_alarm_powerup && !poweron_alarm) {
		spin_lock_irqsave(&rtc_dd->alarm_ctrl_lock, irq_flags);
		spin_lock_irqsave(&rtc_dd->alarm_ctrl_lock, irq_flags);
		dev_dbg(&spmi->dev, "Disabling alarm interrupts\n");
		dev_dbg(&spmi->dev, "Disabling alarm interrupts\n");