Skip to contentSkip to conversation

rtc: max8998: Check for pdata presence before dereferencing

PATCH New Tomasz Figa 4 participants 4 messages May 15, 2013 – May 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtc: max8998: Check for pdata presence before dereferencing

Currently the driver can crash with a NULL pointer dereference if no pdata is provided, despite of successful registration of MFD part. This patch fixes the problem by adding a NULL check before dereferencing the pdata pointer.

---
 drivers/rtc/rtc-max8998.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-max8998.c +1 -1
index 48b6612..d5af7ba 100644
@@ -285,7 +285,7 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 			info->irq, ret);
 
 	dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name);
-	if (pdata->rtc_delay) {
+	if (pdata && pdata->rtc_delay) {
 		info->lp3974_bug_workaround = true;
 		dev_warn(&pdev->dev, "LP3974 with RTC REGERR option."
 				" RTC updates will be extremely slow.\n");
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/1 rtc: max8998: Check for pdata presence before dereferencing

CCing Andrew Morton.

Quoted 31 lines · Tomasz Figa

Currently the driver can crash with a NULL pointer dereference if no pdata is provided, despite of successful registration of MFD part. This patch fixes the problem by adding a NULL check before dereferencing the pdata pointer.

---
 drivers/rtc/rtc-max8998.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-max8998.c +1 -2
index 48b6612..d5af7ba 100644
@@ -285,7 +285,7 @@ static int max8998_rtc_probe(struct platform_device *pdev)
                        info->irq, ret);
 
        dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name);
-       if (pdata->rtc_delay) {
+       if (pdata && pdata->rtc_delay) {
                info->lp3974_bug_workaround = true;
                dev_warn(&pdev->dev, "LP3974 with RTC REGERR option."
                                " RTC updates will be extremely slow.\n");
--

1.8.2.1

--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

Signature · 2 lines
With warm regards,
Sachin
#2 lore raw

PATCH 1/1 rtc: max8998: Check for pdata presence before dereferencing

In reply to Tomasz Figa

Hi Alessandro,

Quoted 16 lines · On Wednesday 15 of May 2013 17:16:08 Tomasz Figa wrote:

Currently the driver can crash with a NULL pointer dereference if no pdata is provided, despite of successful registration of MFD part. This patch fixes the problem by adding a NULL check before dereferencing the pdata pointer.

---
 drivers/rtc/rtc-max8998.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/rtc/rtc-max8998.c +0 -0
index 48b6612..d5af7ba 100644

drivers/rtc/rtc-max8998.c static int max8998_rtc_probe(struct platform_device · line 291

Quoted 8 lines
drivers/rtc/rtc-max8998.c +1 -1
@@ -285,7 +285,7 @@ static int max8998_rtc_probe(struct platform_device
 *pdev) info->irq, ret);
 
 	dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name);
-	if (pdata->rtc_delay) {
+	if (pdata && pdata->rtc_delay) {
 		info->lp3974_bug_workaround = true;
 		dev_warn(&pdev->dev, "LP3974 with RTC REGERR option."
 				" RTC updates will be extremely slow.\n");

Since this is a fix, could you apply this patch to your fixes branch for 3.10-rc2, please?

Best regards,
Tomasz

#3 lore raw

PATCH 1/1 rtc: max8998: Check for pdata presence before dereferencing

In reply to Tomasz Figa
Quoted 10 lines · On Wed, 15 May 2013 17:16:08 +0200 Tomasz Figa <[email protected]> wrote:

Currently the driver can crash with a NULL pointer dereference if no pdata is provided, despite of successful registration of MFD part. This patch fixes the problem by adding a NULL check before dereferencing the pdata pointer.

...

drivers/rtc/rtc-max8998.c static int max8998_rtc_probe(struct platform_device *pdev) · line 291

Quoted 8 lines
drivers/rtc/rtc-max8998.c +1 -1
@@ -285,7 +285,7 @@ static int max8998_rtc_probe(struct platform_device *pdev)
 			info->irq, ret);
 
 	dev_info(&pdev->dev, "RTC CHIP NAME: %s\n", pdev->id_entry->name);
-	if (pdata->rtc_delay) {
+	if (pdata && pdata->rtc_delay) {
 		info->lp3974_bug_workaround = true;
 		dev_warn(&pdev->dev, "LP3974 with RTC REGERR option."
 				" RTC updates will be extremely slow.\n");

Looking at your description I'm unable to determine which kernel versions we should fix. This is because the changelog didn't describe the circumstances under which the bug triggers.

It's pretty simple: when fixing a bug, include a full description of the bug! As if you were sending a bug report, not a patch.