* [PATCH 0/3] [media] mb86a20s: Adjustments for mb86a20s_attach()
@ 2017-08-31 19:55 SF Markus Elfring
2017-08-31 19:56 ` [PATCH 1/3] [media] mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach() SF Markus Elfring
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-31 19:55 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Max Kellermann, Nicolas Iooss
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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(-)
--
2.14.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/3] [media] mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach()
2017-08-31 19:55 [PATCH 0/3] [media] mb86a20s: Adjustments for mb86a20s_attach() SF Markus Elfring
@ 2017-08-31 19:56 ` SF Markus Elfring
2017-08-31 19:57 ` [PATCH 2/3] [media] mb86a20s: Improve a size determination " SF Markus Elfring
2017-08-31 19:58 ` [PATCH 3/3] [media] mb86a20s: Delete a jump target " SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-31 19:56 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Max Kellermann, Nicolas Iooss
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/dvb-frontends/mb86a20s.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index e8ac8c3e2ec0..340984100aec 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -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;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/3] [media] mb86a20s: Improve a size determination in mb86a20s_attach()
2017-08-31 19:55 [PATCH 0/3] [media] mb86a20s: Adjustments for mb86a20s_attach() SF Markus Elfring
2017-08-31 19:56 ` [PATCH 1/3] [media] mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach() SF Markus Elfring
@ 2017-08-31 19:57 ` SF Markus Elfring
2017-08-31 19:58 ` [PATCH 3/3] [media] mb86a20s: Delete a jump target " SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-31 19:57 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Max Kellermann, Nicolas Iooss
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/dvb-frontends/mb86a20s.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index 340984100aec..ba7a433dd424 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -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;
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 3/3] [media] mb86a20s: Delete a jump target in mb86a20s_attach()
2017-08-31 19:55 [PATCH 0/3] [media] mb86a20s: Adjustments for mb86a20s_attach() SF Markus Elfring
2017-08-31 19:56 ` [PATCH 1/3] [media] mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach() SF Markus Elfring
2017-08-31 19:57 ` [PATCH 2/3] [media] mb86a20s: Improve a size determination " SF Markus Elfring
@ 2017-08-31 19:58 ` SF Markus Elfring
2 siblings, 0 replies; 4+ messages in thread
From: SF Markus Elfring @ 2017-08-31 19:58 UTC (permalink / raw)
To: linux-media, Mauro Carvalho Chehab, Max Kellermann, Nicolas Iooss
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/media/dvb-frontends/mb86a20s.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/media/dvb-frontends/mb86a20s.c b/drivers/media/dvb-frontends/mb86a20s.c
index ba7a433dd424..bdaf9d235fed 100644
--- a/drivers/media/dvb-frontends/mb86a20s.c
+++ b/drivers/media/dvb-frontends/mb86a20s.c
@@ -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);
--
2.14.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-08-31 19:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-31 19:55 [PATCH 0/3] [media] mb86a20s: Adjustments for mb86a20s_attach() SF Markus Elfring
2017-08-31 19:56 ` [PATCH 1/3] [media] mb86a20s: Delete an error message for a failed memory allocation in mb86a20s_attach() SF Markus Elfring
2017-08-31 19:57 ` [PATCH 2/3] [media] mb86a20s: Improve a size determination " SF Markus Elfring
2017-08-31 19:58 ` [PATCH 3/3] [media] mb86a20s: Delete a jump target " SF Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).