Bug 13326

Summary: [PATCH]Null pointer dereference in rtc-cmos driver
Product: Drivers Reporter: Rafael J. Wysocki (rjw)
Component: OtherAssignee: drivers_other
Status: CLOSED CODE_FIX    
Severity: normal CC: alan, janboe.ye
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.30-rc5 Subsystem:
Regression: Yes Bisected commit-id:
Bug Depends on:    
Bug Blocks: 13070    
Attachments: Driver Core: do not oops when driver_unregister() is called for unregistered drivers

Description Rafael J. Wysocki 2009-05-16 21:28:15 UTC
Subject    : [BUG 2.6.30_rc5] Null pointer dereference in rtc-cmos driver
Submitter  : Ozan Çağlayan <ozan@pardus.org.tr>
Date       : 2009-05-14 16:16
References : http://marc.info/?l=linux-kernel&m=124231783704696&w=4

This entry is being used for tracking a regression from 2.6.29.  Please don't
close it until the problem is fixed in the mainline.
Comment 1 Janboe Ye 2009-05-17 15:00:07 UTC
This is because rtc-cmos driver continues when pnp_register_driver(&cmos_pnp_driver) fail.

My patch fixes this bug.

diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c
index 23e10b6..da132f6 100644
--- a/drivers/rtc/rtc-cmos.c
+++ b/drivers/rtc/rtc-cmos.c
@@ -1179,7 +1179,9 @@ static int __init cmos_init(void)
        int retval = 0;
 
 #ifdef CONFIG_PNP
-       pnp_register_driver(&cmos_pnp_driver);
+       retval = pnp_register_driver(&cmos_pnp_driver);
+       if (retval)
+               return retval;
 #endif
 
        if (!cmos_rtc.dev)
Comment 2 Rafael J. Wysocki 2009-05-24 22:18:44 UTC
Created attachment 21523 [details]
Driver Core: do not oops when driver_unregister() is called for unregistered drivers

Handled-By : Kay Sievers <kay.sievers@vrfy.org>
Comment 3 Rafael J. Wysocki 2009-05-24 22:19:24 UTC
Patch : http://bugzilla.kernel.org/attachment.cgi?id=21523
Comment 4 Rafael J. Wysocki 2009-05-30 21:31:55 UTC
Fixed by commit 5c8563d773c0e9f0ac2a552e84806decd98ce732 .