Skip to content

Commit 5cfe8f1

Browse files
Jay Estabrookmattst88
authored andcommitted
alpha: Prevent a NULL ptr dereference in csum_partial_copy.
Introduced by 3ddc5b4 ("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: Matt Turner <mattst88@gmail.com>
1 parent 6e22f8f commit 5cfe8f1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

arch/alpha/lib/csum_partial_copy.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ csum_partial_cfu_aligned(const unsigned long __user *src, unsigned long *dst,
130130
*dst = word | tmp;
131131
checksum += carry;
132132
}
133-
if (err) *errp = err;
133+
if (err && errp) *errp = err;
134134
return checksum;
135135
}
136136

@@ -185,7 +185,7 @@ csum_partial_cfu_dest_aligned(const unsigned long __user *src,
185185
*dst = word | tmp;
186186
checksum += carry;
187187
}
188-
if (err) *errp = err;
188+
if (err && errp) *errp = err;
189189
return checksum;
190190
}
191191

@@ -242,7 +242,7 @@ csum_partial_cfu_src_aligned(const unsigned long __user *src,
242242
stq_u(partial_dest | second_dest, dst);
243243
out:
244244
checksum += carry;
245-
if (err) *errp = err;
245+
if (err && errp) *errp = err;
246246
return checksum;
247247
}
248248

@@ -325,7 +325,7 @@ csum_partial_cfu_unaligned(const unsigned long __user * src,
325325
stq_u(partial_dest | word | second_dest, dst);
326326
checksum += carry;
327327
}
328-
if (err) *errp = err;
328+
if (err && errp) *errp = err;
329329
return checksum;
330330
}
331331

@@ -339,7 +339,7 @@ csum_partial_copy_from_user(const void __user *src, void *dst, int len,
339339

340340
if (len) {
341341
if (!access_ok(VERIFY_READ, src, len)) {
342-
*errp = -EFAULT;
342+
if (errp) *errp = -EFAULT;
343343
memset(dst, 0, len);
344344
return sum;
345345
}

0 commit comments

Comments
 (0)