diff mbox series

[FFmpeg-devel,19/23] dnn/dnn_backend_native_layer_conv2d: Check allocation

Message ID 20210310215446.1396386-10-andreas.rheinhardt@gmail.com
State Accepted
Headers show
Series [FFmpeg-devel,1/8] avcodec/cbs: Remove redundant checks for CodedBitstreamContext.codec | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished

Commit Message

Andreas Rheinhardt March 10, 2021, 9:54 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Why does DNN actually not use the ordinary error codes?

 libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Guo, Yejun March 11, 2021, 7:28 a.m. UTC | #1
> -----Original Message-----
> From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> Andreas Rheinhardt
> Sent: 2021年3月11日 5:55
> To: ffmpeg-devel@ffmpeg.org
> Cc: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> Subject: [FFmpeg-devel] [PATCH 19/23]
> dnn/dnn_backend_native_layer_conv2d: Check allocation
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> Why does DNN actually not use the ordinary error codes?

DNN_ERROR/DNN_SUCCESS is introduced at the very beginning,
@Pedro any comment if we need to revisit the error code? thanks.

> 
>  libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> index 94a07c1fdb..941330c895 100644
> --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> @@ -228,6 +228,8 @@ int ff_dnn_execute_layer_conv2d(DnnOperand
> *operands, const int32_t *input_opera
> 
>  #if HAVE_PTHREAD_CANCEL
>      thread_param = av_calloc(thread_num, sizeof(*thread_param));
> +    if (!thread_param)
> +        return DNN_ERROR;

LGTM, thanks.
Pedro Arthur March 11, 2021, 12:43 p.m. UTC | #2
Em qui., 11 de mar. de 2021 às 04:29, Guo, Yejun <yejun.guo@intel.com> escreveu:
>
>
>
> > -----Original Message-----
> > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > Andreas Rheinhardt
> > Sent: 2021年3月11日 5:55
> > To: ffmpeg-devel@ffmpeg.org
> > Cc: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > Subject: [FFmpeg-devel] [PATCH 19/23]
> > dnn/dnn_backend_native_layer_conv2d: Check allocation
> >
> > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > ---
> > Why does DNN actually not use the ordinary error codes?
>
> DNN_ERROR/DNN_SUCCESS is introduced at the very beginning,
> @Pedro any comment if we need to revisit the error code? thanks.

I believe it was used for dnn specific errors and at some point were
mixed with ordinary errors.
I agree we should use ordinary error codes for ordinary errors.

>
> >
> >  libavfilter/dnn/dnn_backend_native_layer_conv2d.c | 2 ++
> >  1 file changed, 2 insertions(+)
> >
> > diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> > b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> > index 94a07c1fdb..941330c895 100644
> > --- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> > +++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
> > @@ -228,6 +228,8 @@ int ff_dnn_execute_layer_conv2d(DnnOperand
> > *operands, const int32_t *input_opera
> >
> >  #if HAVE_PTHREAD_CANCEL
> >      thread_param = av_calloc(thread_num, sizeof(*thread_param));
> > +    if (!thread_param)
> > +        return DNN_ERROR;
>
> LGTM, thanks.
>
Guo, Yejun March 11, 2021, 1:39 p.m. UTC | #3
> -----Original Message-----
> From: Pedro Arthur <bygrandao@gmail.com>
> Sent: 2021年3月11日 20:43
> To: Guo, Yejun <yejun.guo@intel.com>
> Cc: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
> Subject: Re: [FFmpeg-devel] [PATCH 19/23]
> dnn/dnn_backend_native_layer_conv2d: Check allocation
> 
> Em qui., 11 de mar. de 2021 às 04:29, Guo, Yejun <yejun.guo@intel.com>
> escreveu:
> >
> >
> >
> > > -----Original Message-----
> > > From: ffmpeg-devel <ffmpeg-devel-bounces@ffmpeg.org> On Behalf Of
> > > Andreas Rheinhardt
> > > Sent: 2021年3月11日 5:55
> > > To: ffmpeg-devel@ffmpeg.org
> > > Cc: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > > Subject: [FFmpeg-devel] [PATCH 19/23]
> > > dnn/dnn_backend_native_layer_conv2d: Check allocation
> > >
> > > Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> > > ---
> > > Why does DNN actually not use the ordinary error codes?
> >
> > DNN_ERROR/DNN_SUCCESS is introduced at the very beginning, @Pedro any
> > comment if we need to revisit the error code? thanks.
> 
> I believe it was used for dnn specific errors and at some point were mixed with
> ordinary errors.
> I agree we should use ordinary error codes for ordinary errors.

I see, thanks.
diff mbox series

Patch

diff --git a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
index 94a07c1fdb..941330c895 100644
--- a/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
+++ b/libavfilter/dnn/dnn_backend_native_layer_conv2d.c
@@ -228,6 +228,8 @@  int ff_dnn_execute_layer_conv2d(DnnOperand *operands, const int32_t *input_opera
 
 #if HAVE_PTHREAD_CANCEL
     thread_param = av_calloc(thread_num, sizeof(*thread_param));
+    if (!thread_param)
+        return DNN_ERROR;
     thread_stride = (height - pad_size * 2) / thread_num;
     //create threads
     for (int i = 0; i < thread_num; i++){