diff options
-rw-r--r-- | arch/sparc64/kernel/time.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/arch/sparc64/kernel/time.c b/arch/sparc64/kernel/time.c index 0eb846534ff4..3cb761ec8953 100644 --- a/arch/sparc64/kernel/time.c +++ b/arch/sparc64/kernel/time.c | |||
@@ -1177,10 +1177,6 @@ static int set_rtc_mmss(unsigned long nowtime) | |||
1177 | #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ | 1177 | #define RTC_IS_OPEN 0x01 /* means /dev/rtc is in use */ |
1178 | static unsigned char mini_rtc_status; /* bitmapped status byte. */ | 1178 | static unsigned char mini_rtc_status; /* bitmapped status byte. */ |
1179 | 1179 | ||
1180 | /* months start at 0 now */ | ||
1181 | static unsigned char days_in_mo[] = | ||
1182 | {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; | ||
1183 | |||
1184 | #define FEBRUARY 2 | 1180 | #define FEBRUARY 2 |
1185 | #define STARTOFTIME 1970 | 1181 | #define STARTOFTIME 1970 |
1186 | #define SECDAY 86400L | 1182 | #define SECDAY 86400L |
@@ -1329,8 +1325,7 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file, | |||
1329 | 1325 | ||
1330 | case RTC_SET_TIME: /* Set the RTC */ | 1326 | case RTC_SET_TIME: /* Set the RTC */ |
1331 | { | 1327 | { |
1332 | int year; | 1328 | int year, days; |
1333 | unsigned char leap_yr; | ||
1334 | 1329 | ||
1335 | if (!capable(CAP_SYS_TIME)) | 1330 | if (!capable(CAP_SYS_TIME)) |
1336 | return -EACCES; | 1331 | return -EACCES; |
@@ -1339,14 +1334,14 @@ static int mini_rtc_ioctl(struct inode *inode, struct file *file, | |||
1339 | return -EFAULT; | 1334 | return -EFAULT; |
1340 | 1335 | ||
1341 | year = wtime.tm_year + 1900; | 1336 | year = wtime.tm_year + 1900; |
1342 | leap_yr = ((!(year % 4) && (year % 100)) || | 1337 | days = month_days[wtime.tm_mon] + |
1343 | !(year % 400)); | 1338 | ((wtime.tm_mon == 1) && leapyear(year)); |
1344 | 1339 | ||
1345 | if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || (wtime.tm_mday < 1)) | 1340 | if ((wtime.tm_mon < 0 || wtime.tm_mon > 11) || |
1341 | (wtime.tm_mday < 1)) | ||
1346 | return -EINVAL; | 1342 | return -EINVAL; |
1347 | 1343 | ||
1348 | if (wtime.tm_mday < 0 || wtime.tm_mday > | 1344 | if (wtime.tm_mday < 0 || wtime.tm_mday > days) |
1349 | (days_in_mo[wtime.tm_mon] + ((wtime.tm_mon == 1) && leap_yr))) | ||
1350 | return -EINVAL; | 1345 | return -EINVAL; |
1351 | 1346 | ||
1352 | if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || | 1347 | if (wtime.tm_hour < 0 || wtime.tm_hour >= 24 || |