Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Chris Boyd via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: "'ffmpeg-devel@ffmpeg.org'" <ffmpeg-devel@ffmpeg.org>
Cc: Chris Boyd <cboyd@valvesoftware.com>
Subject: [FFmpeg-devel] [PATCH] avutil/cuda_check: add error handling to ff_cuda_check
Date: Thu, 11 Dec 2025 02:51:08 +0000
Message-ID: <b0229e2564d44e19b4d18e7ae6a47ab2@valvesoftware.com> (raw)

Add variable initialization and return value checks when calling
cuGetErrorName() and cuGetErrorString(). Although the documentation for
these methods seems to imply that the provided char* will be set to NULL
on failure, we have seen crashes when logging these strings with
uninitialized memory on machines that have Nvidia drivers installed but
no longer have an Nvidia GPU.

Signed-off-by: Christopher Boyd <cboyd@valvesoftware.com>
---
 libavutil/cuda_check.h | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/libavutil/cuda_check.h b/libavutil/cuda_check.h
index f5a9234eaf..763009ce92 100644
--- a/libavutil/cuda_check.h
+++ b/libavutil/cuda_check.h
@@ -33,16 +33,22 @@ static inline int ff_cuda_check(void *avctx,
                                 void *cuGetErrorName_fn, void *cuGetErrorString_fn,
                                 CUresult err, const char *func)
 {
-    const char *err_name;
-    const char *err_string;
+    const char *err_name = NULL;
+    const char *err_string = NULL;
+    CUresult get_err;
 
     av_log(avctx, AV_LOG_TRACE, "Calling %s\n", func);
 
     if (err == CUDA_SUCCESS)
         return 0;
 
-    ((cuda_check_GetErrorName *)cuGetErrorName_fn)(err, &err_name);
-    ((cuda_check_GetErrorString *)cuGetErrorString_fn)(err, &err_string);
+    get_err = ((cuda_check_GetErrorName *)cuGetErrorName_fn)(err, &err_name);
+    if (get_err != CUDA_SUCCESS)
+        err_name = NULL;
+
+    get_err = ((cuda_check_GetErrorString *)cuGetErrorString_fn)(err, &err_string);
+    if (get_err != CUDA_SUCCESS)
+        err_string = NULL;
 
     av_log(avctx, AV_LOG_ERROR, "%s failed", func);
     if (err_name && err_string)
-- 
2.43.0

_______________________________________________
ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org

             reply	other threads:[~2025-12-11  2:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-11  2:51 Chris Boyd via ffmpeg-devel [this message]
2025-12-11 17:52 ` [FFmpeg-devel] " Timo Rothenpieler via ffmpeg-devel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b0229e2564d44e19b4d18e7ae6a47ab2@valvesoftware.com \
    --to=ffmpeg-devel@ffmpeg.org \
    --cc=cboyd@valvesoftware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git