diff --git a/libavcodec/qsv.c b/libavcodec/qsv.c
index 3e892e853ce55315961d1a27f68be444757f48bb..e08518be24947667b5d5223285f7ee331c643fea 100644
--- a/libavcodec/qsv.c
+++ b/libavcodec/qsv.c
@@ -133,6 +133,8 @@ int ff_qsv_init_internal_session(AVCodecContext *avctx, mfxSession *session,
                 goto load_plugin_fail;
             }
 
+            if (*load_plugins)
+                load_plugins++;
 load_plugin_fail:
             av_freep(&plugin);
             if (err < 0)