[POWERPC] Fix VDSO gettimeofday() when called with NULL struct timeval

Consider the prototype for gettimeofday():
int gettimofday(struct timeval *tv, struct timezone *tz);

Although it is valid to call with /either/ tv or tz being NULL, and
the C version of sys_gettimeofday() supports this, the current version
of gettimeofday() in the VDSO will SEGV if called with a NULL tv.

This adds a check for tv being NULL so that it doesn't SEGV.

Signed-off-by: Tony Breeds <tony@bakeyournoodle.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>

authored by Tony Breeds and committed by Paul Mackerras 74609f45 ca74c013

+7 -4
+3 -1
arch/powerpc/kernel/vdso32/gettimeofday.S
··· 32 32 mr r11,r4 /* r11 saves tz */ 33 33 bl __get_datapage@local /* get data page */ 34 34 mr r9, r3 /* datapage ptr in r9 */ 35 + cmplwi r10,0 /* check if tv is NULL */ 36 + beq 3f 35 37 bl __do_get_xsec@local /* get xsec from tb & kernel */ 36 38 bne- 2f /* out of line -> do syscall */ 37 39 ··· 52 50 mulhwu r5,r5,r6 53 51 stw r5,TVAL32_TV_USEC(r10) 54 52 55 - cmpli cr0,r11,0 /* check if tz is NULL */ 53 + 3: cmplwi r11,0 /* check if tz is NULL */ 56 54 beq 1f 57 55 lwz r4,CFG_TZ_MINUTEWEST(r9)/* fill tz */ 58 56 lwz r5,CFG_TZ_DSTTIME(r9)
+4 -3
arch/powerpc/kernel/vdso64/gettimeofday.S
··· 1 - 2 - /* 1 + /* 3 2 * Userland implementation of gettimeofday() for 64 bits processes in a 4 3 * ppc64 kernel for use in the vDSO 5 4 * ··· 31 32 mr r11,r3 /* r11 holds tv */ 32 33 mr r10,r4 /* r10 holds tz */ 33 34 bl V_LOCAL_FUNC(__get_datapage) /* get data page */ 35 + cmpldi r10,0 /* check if tv is NULL */ 36 + beq 2f 34 37 bl V_LOCAL_FUNC(__do_get_xsec) /* get xsec from tb & kernel */ 35 38 lis r7,15 /* r7 = 1000000 = USEC_PER_SEC */ 36 39 ori r7,r7,16960 ··· 44 43 * XSEC_PER_SEC 45 44 */ 46 45 rldicl r0,r0,44,20 47 - cmpldi cr0,r10,0 /* check if tz is NULL */ 48 46 std r0,TVAL64_TV_USEC(r11) /* store usec in tv */ 47 + 2: cmpldi r10,0 /* check if tz is NULL */ 49 48 beq 1f 50 49 lwz r4,CFG_TZ_MINUTEWEST(r3)/* fill tz */ 51 50 lwz r5,CFG_TZ_DSTTIME(r3)