summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2024-10-11 02:33:12 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2024-10-11 02:33:12 +0000
commit73bcb7c7c07e48c86aeeefebf42d5889e921b990 (patch)
tree0333eaa7af25b8af7f38044e4eddba7ae5a73e06 /sys
parente1a254fcc8c1f3fe67e357b237957d2c0932895a (diff)
drm/printer: Allow NULL data in devcoredump printer
From Matthew Brost 4ee08b4a7201ba0f7f3d52e3840fee92f415b6c5 in linux-6.6.y/6.6.55 53369581dc0c68a5700ed51e1660f44c4b2bb524 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/drm_print.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/dev/pci/drm/drm_print.c b/sys/dev/pci/drm/drm_print.c
index 68c810e2d7b..da63a054a0d 100644
--- a/sys/dev/pci/drm/drm_print.c
+++ b/sys/dev/pci/drm/drm_print.c
@@ -104,8 +104,9 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
copy = iterator->remain;
/* Copy out the bit of the string that we need */
- memcpy(iterator->data,
- str + (iterator->start - iterator->offset), copy);
+ if (iterator->data)
+ memcpy(iterator->data,
+ str + (iterator->start - iterator->offset), copy);
iterator->offset = iterator->start + copy;
iterator->remain -= copy;
@@ -114,7 +115,8 @@ void __drm_puts_coredump(struct drm_printer *p, const char *str)
len = min_t(ssize_t, strlen(str), iterator->remain);
- memcpy(iterator->data + pos, str, len);
+ if (iterator->data)
+ memcpy(iterator->data + pos, str, len);
iterator->offset += len;
iterator->remain -= len;
@@ -144,8 +146,9 @@ void __drm_printfn_coredump(struct drm_printer *p, struct va_format *vaf)
if ((iterator->offset >= iterator->start) && (len < iterator->remain)) {
ssize_t pos = iterator->offset - iterator->start;
- snprintf(((char *) iterator->data) + pos,
- iterator->remain, "%pV", vaf);
+ if (iterator->data)
+ snprintf(((char *) iterator->data) + pos,
+ iterator->remain, "%pV", vaf);
iterator->offset += len;
iterator->remain -= len;