Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

rtc: nct3018y: fix possible NULL dereference

alarm_enable and alarm_flag are allowed to be NULL but will be dereferenced
later by the dev_dbg call.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Closes: https://lore.kernel.org/r/202305180042.DEzW1pSd-lkp@intel.com/
Link: https://lore.kernel.org/r/20240229222127.1878176-1-alexandre.belloni@bootlin.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

+3 -3
+3 -3
drivers/rtc/rtc-nct3018y.c
··· 102 102 if (flags < 0) 103 103 return flags; 104 104 *alarm_enable = flags & NCT3018Y_BIT_AIE; 105 + dev_dbg(&client->dev, "%s:alarm_enable:%x\n", __func__, *alarm_enable); 106 + 105 107 } 106 108 107 109 if (alarm_flag) { ··· 112 110 if (flags < 0) 113 111 return flags; 114 112 *alarm_flag = flags & NCT3018Y_BIT_AF; 113 + dev_dbg(&client->dev, "%s:alarm_flag:%x\n", __func__, *alarm_flag); 115 114 } 116 - 117 - dev_dbg(&client->dev, "%s:alarm_enable:%x alarm_flag:%x\n", 118 - __func__, *alarm_enable, *alarm_flag); 119 115 120 116 return 0; 121 117 }