From patchwork Wed Jul 31 21:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Brost X-Patchwork-Id: 13749240 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D7BBC3DA7F for ; Wed, 31 Jul 2024 21:31:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D17C10E6D1; Wed, 31 Jul 2024 21:31:42 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="RmGf70yB"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id BD80B10E6D0; Wed, 31 Jul 2024 21:31:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1722461500; x=1753997500; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=au3TGgfpi/Lgdi9QsgHL3ol5Ks1DJ8E3L9NSvnmbXd0=; b=RmGf70yBhEtKS9JCY63FT2gMNbgS2vl9N3DhisUzGfAsOdQYMd5F+YQ2 745rDQegjZso2MnlYRrE1akCRy4LTP6QUiPUVws2XOzJRGt+R0k0V8wsf Cm0dA0FSxkFL0PiTv7LEuSIk8yqG9LVPpVV5ZGDz0rrytYrmXFF7QP6YD v18U+QwQJU4phYPeY1uU9l1iroyB1ZfQxUXObdn054hQuUN4wGSOCrFIi HIVnMt/vrPuRYZAc4Z0XhURErkawqbeHIKKMdCWn85DwEWEQhc5MaPRwD T3KPuBRuKvN6KKXiNVXD0/9UErB6JhH4CEUJjWH9+lXtQqfrQVUwMBwEO Q==; X-CSE-ConnectionGUID: SfRc8Gn3Tb2K3xOClcVABA== X-CSE-MsgGUID: UF2et8OHRSOaCudVifq9Xg== X-IronPort-AV: E=McAfee;i="6700,10204,11150"; a="24234740" X-IronPort-AV: E=Sophos;i="6.09,251,1716274800"; d="scan'208";a="24234740" Received: from fmviesa003.fm.intel.com ([10.60.135.143]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2024 14:31:39 -0700 X-CSE-ConnectionGUID: G8LMnLfcTdOhYFTXg8AX5Q== X-CSE-MsgGUID: YM+eEjTDRRKKbceW+clEbw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,251,1716274800"; d="scan'208";a="58938906" Received: from lstrano-desk.jf.intel.com ([10.54.39.91]) by fmviesa003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 Jul 2024 14:31:41 -0700 From: Matthew Brost To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org Cc: maarten.lankhorst@linux.intel.com, rodrigo.vivi@intel.com Subject: [PATCH v4 2/3] drm/printer: Allow NULL data in devcoredump printer Date: Wed, 31 Jul 2024 14:32:20 -0700 Message-Id: <20240731213221.2523989-3-matthew.brost@intel.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240731213221.2523989-1-matthew.brost@intel.com> References: <20240731213221.2523989-1-matthew.brost@intel.com> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Useful to determine size of devcoreump before writing it out. Cc: Maarten Lankhorst Signed-off-by: Matthew Brost Reviewed-by: Jonathan Cavitt --- drivers/gpu/drm/drm_print.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index cf24dfdeb6b2..a1a4de9f9c44 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -100,8 +100,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; @@ -110,7 +111,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; @@ -140,8 +142,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;