mb86a20s: Adjustments for mb86a20s_attach()
Subsystems (2)
cover mb86a20s: Adjustments for mb86a20s_attach()
From: Markus Elfring <[email protected]>
Date: Thu, 31 Aug 2017 21:46:12 +0200
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
Delete an error message for a failed memory allocation Improve a size determination
Delete a jump target
drivers/media/dvb-frontends/mb86a20s.c | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/3 mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach()
From: Markus Elfring <[email protected]>
Date: Thu, 31 Aug 2017 21:10:25 +0200
Omit an extra message for a memory allocation failure in this function.
This issue was detected by using the Coccinelle software.
--- drivers/media/dvb-frontends/mb86a20s.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +1 -4
@@ -2075,8 +2075,5 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config, -if (state =NULL ) { -dev_err (&i2c->dev, -"%s: unable to allocate memory for state\n" , __func__); +if (!state) goto error; - }/* setup the state */ state->config = config;
Signature · 1 line
2.14.1
PATCH 2/3 mb86a20s: Improve a size determination in mb86a20s_attach()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Aug 2017 21:13:26 +0200
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
This issue was detected by using the Coccinelle software.
--- drivers/media/dvb-frontends/mb86a20s.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/media/dvb-frontends/mb86a20s.c +1 -1
@@ -2071,7 +2071,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,dev_dbg (&i2c->dev,"%s called.\n" , __func__);/* allocate memory for the internal state */ - state =kzalloc (sizeof (struct mb86a20s_state ),GFP_KERNEL ); + state =kzalloc (sizeof (*state),GFP_KERNEL );if (!state) goto error;
Signature · 1 line
2.14.1
PATCH 3/3 mb86a20s: Delete a jump target in mb86a20s_attach()
In reply to SF Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Thu, 31 Aug 2017 21:34:58 +0200
* Return directly after a call of the function "kzalloc" failed at the beginning.
* Move a bit of exception handling code into an if branch.
* Adjust a condition check.
* Delete the jump target "error" which became unnecessary with this refactoring.
--- drivers/media/dvb-frontends/mb86a20s.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-)
drivers/media/dvb-frontends/mb86a20s.c +5 -11
@@ -2073,7 +2073,7 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,/* allocate memory for the internal state */ state =kzalloc (sizeof (*state),GFP_KERNEL );if (!state) - goto error; +return NULL ;/* setup the state */ state->config = config;
@@ -2086,22 +2086,16 @@ struct dvb_frontend *mb86a20s_attach(const struct mb86a20s_config *config,/* Check if it is a mb86a20s frontend */ rev =mb86a20s_readreg (state,0 ); - -if (rev =0x13 ) { -dev_info (&i2c->dev, -"Detected a Fujitsu mb86a20s frontend\n" ); - }else { +if (rev !=0x13 ) { +kfree (state);dev_dbg (&i2c->dev,"Frontend revision %d is unknown - aborting.\n" , rev); - goto error; +return NULL ; } +dev_info (&i2c->dev,"Detected a Fujitsu mb86a20s frontend\n" );return &state->frontend; - -error: -kfree (state); -return NULL ; }EXPORT_SYMBOL (mb86a20s_attach);
Signature · 1 line
2.14.1