Commit 5cfe8f1b authored by Jay Estabrook's avatar Jay Estabrook Committed by Matt Turner

alpha: Prevent a NULL ptr dereference in csum_partial_copy.

Introduced by 3ddc5b46 ("kernel-wide: fix missing validations
on __get/__put/__copy_to/__copy_from_user()").

Also fix some other places which could be problematic in a similar way,
although they hadn't been proved so, as far as I can tell.

Cc: Michael Cree <mcree@orcon.net.nz>
Signed-off-by: default avatarMatt Turner <mattst88@gmail.com>
parent 6e22f8f2
...@@ -130,7 +130,7 @@ csum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst, ...@@ -130,7 +130,7 @@ csum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst,
*dst = word | tmp; *dst = word | tmp;
checksum += carry; checksum += carry;
} }
if (err) *errp = err; if (err && errp) *errp = err;
return checksum; return checksum;
} }
...@@ -185,7 +185,7 @@ csum_partial_cfu_dest_aligned(const unsigned long __user *src, ...@@ -185,7 +185,7 @@ csum_partial_cfu_dest_aligned(const unsigned long __user *src,
*dst = word | tmp; *dst = word | tmp;
checksum += carry; checksum += carry;
} }
if (err) *errp = err; if (err && errp) *errp = err;
return checksum; return checksum;
} }
...@@ -242,7 +242,7 @@ csum_partial_cfu_src_aligned(const unsigned long __user *src, ...@@ -242,7 +242,7 @@ csum_partial_cfu_src_aligned(const unsigned long __user *src,
stq_u(partial_dest | second_dest, dst); stq_u(partial_dest | second_dest, dst);
out: out:
checksum += carry; checksum += carry;
if (err) *errp = err; if (err && errp) *errp = err;
return checksum; return checksum;
} }
...@@ -325,7 +325,7 @@ csum_partial_cfu_unaligned(const unsigned long __user * src, ...@@ -325,7 +325,7 @@ csum_partial_cfu_unaligned(const unsigned long __user * src,
stq_u(partial_dest | word | second_dest, dst); stq_u(partial_dest | word | second_dest, dst);
checksum += carry; checksum += carry;
} }
if (err) *errp = err; if (err && errp) *errp = err;
return checksum; return checksum;
} }
...@@ -339,7 +339,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len, ...@@ -339,7 +339,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
if (len) { if (len) {
if (!access_ok(VERIFY_READ, src, len)) { if (!access_ok(VERIFY_READ, src, len)) {
*errp = -EFAULT; if (errp) *errp = -EFAULT;
memset(dst, 0, len); memset(dst, 0, len);
return sum; return sum;
} }
......
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