aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/snp
diff options
context:
space:
mode:
authorDima Dorfman <dd@FreeBSD.org>2001-08-16 06:00:57 +0000
committerDima Dorfman <dd@FreeBSD.org>2001-08-16 06:00:57 +0000
commite692c40ce1f70f1dc3306f942bbeb0e4a011a966 (patch)
treecaa5f823f34503f1761fea8e9984ffd513244e83 /sys/dev/snp
parent2f46ebcdb7c6e5ea0cee3237188982d0df88c8a9 (diff)
Notes
Diffstat (limited to 'sys/dev/snp')
-rw-r--r--sys/dev/snp/snp.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/dev/snp/snp.c b/sys/dev/snp/snp.c
index c8b9cf099bbd..08eae23d522c 100644
--- a/sys/dev/snp/snp.c
+++ b/sys/dev/snp/snp.c
@@ -141,14 +141,17 @@ snplwrite(tp, uio, flag)
struct uio uio2;
struct snoop *snp;
int error, ilen;
- char ibuf[512];
+ char *ibuf;
+ error = 0;
+ ibuf = NULL;
snp = tp->t_sc;
while (uio->uio_resid > 0) {
- ilen = imin(sizeof(ibuf), uio->uio_resid);
+ ilen = imin(512, uio->uio_resid);
+ ibuf = malloc(ilen, M_SNP, M_WAITOK);
error = uiomove(ibuf, ilen, uio);
if (error != 0)
- return (error);
+ break;
snp_in(snp, ibuf, ilen);
/* Hackish, but probably the least of all evils. */
iov.iov_base = ibuf;
@@ -162,9 +165,13 @@ snplwrite(tp, uio, flag)
uio2.uio_procp = uio->uio_procp;
error = ttwrite(tp, &uio2, flag);
if (error != 0)
- return (error);
+ break;
+ free(ibuf, M_SNP);
+ ibuf = NULL;
}
- return (0);
+ if (ibuf != NULL)
+ free(ibuf, M_SNP);
+ return (error);
}
static struct tty *