media: dvb_dummy_fe: Add error messages in case of attach failure
PATCH 1/1 media: dvb_dummy_fe: Add error messages in case of attach failure
From: "Daniel W. S. Almeida" <[email protected]>
Complain if the attach functions fail, for any reason. This is helpful when debugging.
--- drivers/media/dvb-frontends/dvb_dummy_fe.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)
drivers/media/dvb-frontends/dvb_dummy_fe.c +15 -3
@@ -114,12 +114,16 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_ofdm_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;
@@ -131,12 +135,16 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_qpsk_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;
@@ -148,12 +156,16 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_qam_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
Signature · 1 line
2.24.0
Mauro Carvalho Chehab
maintainerEm Wed, 6 Nov 2019 22:37:45 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:
Quoted 7 lines
From: "Daniel W. S. Almeida" <[email protected]>
Complain if the attach functions fail, for any reason. This is helpful when debugging.
Suggested-by Shuah Khan <[email protected]>Signed-off-by Daniel W. S. Almeida <[email protected]>
Looks OK to me.
Quoted 52 lines
--- drivers/media/dvb-frontends/dvb_dummy_fe.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)drivers/media/dvb-frontends/dvb_dummy_fe.c +11
-3@@ -114,12 +114,16 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_ofdm_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;@@ -131,12 +135,16 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_qpsk_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;@@ -148,12 +156,16 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */
drivers/media/dvb-frontends/dvb_dummy_fe.c struct dvb_frontend *dvb_dummy_fe_qam_attach(void) · line 171
Quoted 10 lines
drivers/media/dvb-frontends/dvb_dummy_fe.c +4
-0memcpy (&state->frontend.ops, &dvb_dummy_fe_qam_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {
Cheers,
Mauro
Hi Daniel, Mauro,
Quoted 28 lines · Mauro Carvalho Chehab
Em Wed, 6 Nov 2019 22:37:45 -0300
"Daniel W. S. Almeida" <[email protected]> escreveu:Quoted 7 lines
From: "Daniel W. S. Almeida" <[email protected]>
Complain if the attach functions fail, for any reason. This is helpful when debugging.
Suggested-by Shuah Khan <[email protected]>Signed-off-by Daniel W. S. Almeida <[email protected]>Looks OK to me.
Quoted 15 lines
--- drivers/media/dvb-frontends/dvb_dummy_fe.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-)drivers/media/dvb-frontends/dvb_dummy_fe.c +1
-1@@ -114,12 +114,16 @@ struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;
Quoted 9 lines
drivers/media/dvb-frontends/dvb_dummy_fe.c struct dvb_frontend* dvb_dummy_fe_ofdm_attach(void) · line 127
Quoted 9 lines
drivers/media/dvb-frontends/dvb_dummy_fe.c +4
-0/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_ofdm_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }
If kzalloc() fails, it will already complain before returning. Lately we've been removing error logs after kmalloc() failures. I'm sure someone will send in patches reverting this if it gets merged.
Is this a good idea?
Sean
Quoted 43 lines
Quoted 28 lines
drivers/media/dvb-frontends/dvb_dummy_fe.c +6
-2static const struct dvb_frontend_ops dvb_dummy_fe_qpsk_ops;@@ -131,12 +135,16 @@ struct dvb_frontend *dvb_dummy_fe_qpsk_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ memcpy (&state->frontend.ops, &dvb_dummy_fe_qpsk_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_qam_ops;@@ -148,12 +156,16 @@ struct dvb_frontend *dvb_dummy_fe_qam_attach(void)/* allocate memory for the internal state */ state =kzalloc (sizeof (struct dvb_dummy_fe_state ),GFP_KERNEL );if (!state) -return NULL ; + goto err;/* create dvb_frontend */ drivers/media/dvb-frontends/dvb_dummy_fe.c struct dvb_frontend *dvb_dummy_fe_qam_attach(void) · line 171
Quoted 10 lines
drivers/media/dvb-frontends/dvb_dummy_fe.c +4
-0memcpy (&state->frontend.ops, &dvb_dummy_fe_qam_ops,sizeof (struct dvb_frontend_ops )); state->frontend.demodulator_priv = state;return &state->frontend; + +err: +pr_err ("%s: DVB Dummy frontend driver attach failed\n" , __func__); +return NULL ; }static const struct dvb_frontend_ops dvb_dummy_fe_ofdm_ops = {Cheers,
Mauro