Commit 3acbeb56 authored by William Stinson's avatar William Stinson Committed by Jeff Garzik

[janitor] update the istallion.c multiport serial driver

	1) checks the result of copy_XX_user and returns -EFAULT in case not all data was copied. 
	2) Patch changes the return code of stl_getserial() from void to int in order to return error code in case of failure.
	3) Patch also fixes two instances of the uninitialised string name being used on request_region calls

I don't have this hardware so compilation checked only.
parent d4badc21
...@@ -712,7 +712,7 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio ...@@ -712,7 +712,7 @@ static void stli_mkasyport(stliport_t *portp, asyport_t *pp, struct termios *tio
static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts); static void stli_mkasysigs(asysigs_t *sp, int dtr, int rts);
static long stli_mktiocm(unsigned long sigvalue); static long stli_mktiocm(unsigned long sigvalue);
static void stli_read(stlibrd_t *brdp, stliport_t *portp); static void stli_read(stlibrd_t *brdp, stliport_t *portp);
static void stli_getserial(stliport_t *portp, struct serial_struct *sp); static int stli_getserial(stliport_t *portp, struct serial_struct *sp);
static int stli_setserial(stliport_t *portp, struct serial_struct *sp); static int stli_setserial(stliport_t *portp, struct serial_struct *sp);
static int stli_getbrdstats(combrd_t *bp); static int stli_getbrdstats(combrd_t *bp);
static int stli_getportstats(stliport_t *portp, comstats_t *cp); static int stli_getportstats(stliport_t *portp, comstats_t *cp);
...@@ -1676,7 +1676,8 @@ static int stli_write(struct tty_struct *tty, int from_user, const unsigned char ...@@ -1676,7 +1676,8 @@ static int stli_write(struct tty_struct *tty, int from_user, const unsigned char
restore_flags(flags); restore_flags(flags);
down(&stli_tmpwritesem); down(&stli_tmpwritesem);
copy_from_user(stli_tmpwritebuf, chbuf, count); if (copy_from_user(stli_tmpwritebuf, chbuf, count))
return -EFAULT;
chbuf = &stli_tmpwritebuf[0]; chbuf = &stli_tmpwritebuf[0];
} }
...@@ -1977,7 +1978,7 @@ static int stli_charsinbuffer(struct tty_struct *tty) ...@@ -1977,7 +1978,7 @@ static int stli_charsinbuffer(struct tty_struct *tty)
* Generate the serial struct info. * Generate the serial struct info.
*/ */
static void stli_getserial(stliport_t *portp, struct serial_struct *sp) static int stli_getserial(stliport_t *portp, struct serial_struct *sp)
{ {
struct serial_struct sio; struct serial_struct sio;
stlibrd_t *brdp; stlibrd_t *brdp;
...@@ -2002,7 +2003,8 @@ static void stli_getserial(stliport_t *portp, struct serial_struct *sp) ...@@ -2002,7 +2003,8 @@ static void stli_getserial(stliport_t *portp, struct serial_struct *sp)
if (brdp != (stlibrd_t *) NULL) if (brdp != (stlibrd_t *) NULL)
sio.port = brdp->iobase; sio.port = brdp->iobase;
copy_to_user(sp, &sio, sizeof(struct serial_struct)); return copy_to_user(sp, &sio, sizeof(struct serial_struct)) ?
-EFAULT : 0;
} }
/*****************************************************************************/ /*****************************************************************************/
...@@ -2129,7 +2131,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm ...@@ -2129,7 +2131,7 @@ static int stli_ioctl(struct tty_struct *tty, struct file *file, unsigned int cm
case TIOCGSERIAL: case TIOCGSERIAL:
if ((rc = verify_area(VERIFY_WRITE, (void *) arg, if ((rc = verify_area(VERIFY_WRITE, (void *) arg,
sizeof(struct serial_struct))) == 0) sizeof(struct serial_struct))) == 0)
stli_getserial(portp, (struct serial_struct *) arg); rc = stli_getserial(portp, (struct serial_struct *) arg);
break; break;
case TIOCSSERIAL: case TIOCSSERIAL:
if ((rc = verify_area(VERIFY_READ, (void *) arg, if ((rc = verify_area(VERIFY_READ, (void *) arg,
...@@ -3972,7 +3974,7 @@ static inline int stli_initecp(stlibrd_t *brdp) ...@@ -3972,7 +3974,7 @@ static inline int stli_initecp(stlibrd_t *brdp)
printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp); printk(KERN_DEBUG "stli_initecp(brdp=%x)\n", (int) brdp);
#endif #endif
if (!request_region(brdp->iobase, brdp->iosize, name)) if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
return -EIO; return -EIO;
if ((brdp->iobase == 0) || (brdp->memaddr == 0)) if ((brdp->iobase == 0) || (brdp->memaddr == 0))
...@@ -4140,7 +4142,7 @@ static inline int stli_initonb(stlibrd_t *brdp) ...@@ -4140,7 +4142,7 @@ static inline int stli_initonb(stlibrd_t *brdp)
brdp->iosize = ONB_IOSIZE; brdp->iosize = ONB_IOSIZE;
if (!request_region(brdp->iobase, brdp->iosize, name)) if (!request_region(brdp->iobase, brdp->iosize, "istallion"))
return -EIO; return -EIO;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment