v9fs_put_str used to store pointer to the source string, instead of the
cbuf copy. This patch corrects it.
Signed-off-by: Latchesar Ionkov <lucho@ionkov.net>
Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-static void buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
+static char *buf_put_stringn(struct cbuf *buf, const char *s, u16 slen)
+ char *ret;
+
+ ret = NULL;
if (buf_check_size(buf, slen + 2)) {
buf_put_int16(buf, slen);
if (buf_check_size(buf, slen + 2)) {
buf_put_int16(buf, slen);
memcpy(buf->p, s, slen);
buf->p += slen;
}
memcpy(buf->p, s, slen);
buf->p += slen;
}
}
static inline void buf_put_string(struct cbuf *buf, const char *s)
}
static inline void buf_put_string(struct cbuf *buf, const char *s)
static void
v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
{
static void
v9fs_put_str(struct cbuf *bufp, char *data, struct v9fs_str *str)
{
- if (data) {
- str->len = strlen(data);
- str->str = bufp->p;
- } else {
- str->len = 0;
- str->str = NULL;
- }
+ int len;
+ char *s;
+
+ if (data)
+ len = strlen(data);
+ else
+ len = 0;
- buf_put_stringn(bufp, data, str->len);
+ s = buf_put_stringn(bufp, data, len);
+ if (str) {
+ str->len = len;
+ str->str = s;
+ }