* [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant
@ 2016-08-16 8:15 LABBE Corentin
2016-08-16 8:15 ` [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference LABBE Corentin
2016-08-31 9:20 ` [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant Lee Jones
0 siblings, 2 replies; 4+ messages in thread
From: LABBE Corentin @ 2016-08-16 8:15 UTC (permalink / raw)
To: lee.jones; +Cc: linux-kernel, LABBE Corentin
The mc13xxx_variant structure is never modified, this patch set it as
const.
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
drivers/mfd/mc13xxx-core.c | 6 +++---
drivers/mfd/mc13xxx-i2c.c | 2 +-
drivers/mfd/mc13xxx-spi.c | 2 +-
drivers/mfd/mc13xxx.h | 2 +-
4 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
index d7f54e4..3a008e6 100644
--- a/drivers/mfd/mc13xxx-core.c
+++ b/drivers/mfd/mc13xxx-core.c
@@ -202,19 +202,19 @@ static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
}
/* These are only exported for mc13xxx-i2c and mc13xxx-spi */
-struct mc13xxx_variant mc13xxx_variant_mc13783 = {
+const struct mc13xxx_variant mc13xxx_variant_mc13783 = {
.name = "mc13783",
.print_revision = mc13xxx_print_revision,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783);
-struct mc13xxx_variant mc13xxx_variant_mc13892 = {
+const struct mc13xxx_variant mc13xxx_variant_mc13892 = {
.name = "mc13892",
.print_revision = mc13xxx_print_revision,
};
EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892);
-struct mc13xxx_variant mc13xxx_variant_mc34708 = {
+const struct mc13xxx_variant mc13xxx_variant_mc34708 = {
.name = "mc34708",
.print_revision = mc34708_print_revision,
};
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
index 67e4c9a..3c00ccb 100644
--- a/drivers/mfd/mc13xxx-i2c.c
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -82,7 +82,7 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
of_match_device(mc13xxx_dt_ids, &client->dev);
mc13xxx->variant = of_id->data;
} else {
- mc13xxx->variant = (void *)id->driver_data;
+ mc13xxx->variant = (const struct mc13xxx_variant *)id->driver_data;
}
return mc13xxx_common_init(&client->dev);
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index cbc1e5e..6100025 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -162,7 +162,7 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
} else {
const struct spi_device_id *id_entry = spi_get_device_id(spi);
- mc13xxx->variant = (void *)id_entry->driver_data;
+ mc13xxx->variant = (const struct mc13xxx_variant *)id_entry->driver_data;
}
return mc13xxx_common_init(&spi->dev);
diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
index 33677d1..6d7fce5 100644
--- a/drivers/mfd/mc13xxx.h
+++ b/drivers/mfd/mc13xxx.h
@@ -24,7 +24,7 @@ struct mc13xxx_variant {
void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision);
};
-extern struct mc13xxx_variant
+extern const struct mc13xxx_variant
mc13xxx_variant_mc13783,
mc13xxx_variant_mc13892,
mc13xxx_variant_mc34708;
--
2.7.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference
2016-08-16 8:15 [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant LABBE Corentin
@ 2016-08-16 8:15 ` LABBE Corentin
2016-08-31 9:23 ` Lee Jones
2016-08-31 9:20 ` [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant Lee Jones
1 sibling, 1 reply; 4+ messages in thread
From: LABBE Corentin @ 2016-08-16 8:15 UTC (permalink / raw)
To: lee.jones; +Cc: linux-kernel, LABBE Corentin
of_match_device could return NULL, and so cause a NULL pointer
dereference later.
For fixing this problem, we use of_device_get_match_data(), this will
simplify the code a little by using a standard function for
getting the match data.
Reported-by: coverity (CID 986513)
Reported-by: coverity (CID 986514)
Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
---
drivers/mfd/mc13xxx-i2c.c | 4 +---
drivers/mfd/mc13xxx-spi.c | 5 +----
2 files changed, 2 insertions(+), 7 deletions(-)
diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
index 3c00ccb..8ad7593 100644
--- a/drivers/mfd/mc13xxx-i2c.c
+++ b/drivers/mfd/mc13xxx-i2c.c
@@ -78,9 +78,7 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
}
if (client->dev.of_node) {
- const struct of_device_id *of_id =
- of_match_device(mc13xxx_dt_ids, &client->dev);
- mc13xxx->variant = of_id->data;
+ mc13xxx->variant = of_device_get_match_data(&client->dev);
} else {
mc13xxx->variant = (const struct mc13xxx_variant *)id->driver_data;
}
diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
index 6100025..3b4f5ba 100644
--- a/drivers/mfd/mc13xxx-spi.c
+++ b/drivers/mfd/mc13xxx-spi.c
@@ -155,10 +155,7 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
}
if (spi->dev.of_node) {
- const struct of_device_id *of_id =
- of_match_device(mc13xxx_dt_ids, &spi->dev);
-
- mc13xxx->variant = of_id->data;
+ mc13xxx->variant = of_device_get_match_data(&spi->dev);
} else {
const struct spi_device_id *id_entry = spi_get_device_id(spi);
--
2.7.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant
2016-08-16 8:15 [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant LABBE Corentin
2016-08-16 8:15 ` [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference LABBE Corentin
@ 2016-08-31 9:20 ` Lee Jones
1 sibling, 0 replies; 4+ messages in thread
From: Lee Jones @ 2016-08-31 9:20 UTC (permalink / raw)
To: LABBE Corentin; +Cc: linux-kernel
On Tue, 16 Aug 2016, LABBE Corentin wrote:
> The mc13xxx_variant structure is never modified, this patch set it as
> const.
>
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Any chance you can uncapitalise your whole name?
> ---
> drivers/mfd/mc13xxx-core.c | 6 +++---
> drivers/mfd/mc13xxx-i2c.c | 2 +-
> drivers/mfd/mc13xxx-spi.c | 2 +-
> drivers/mfd/mc13xxx.h | 2 +-
> 4 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mfd/mc13xxx-core.c b/drivers/mfd/mc13xxx-core.c
> index d7f54e4..3a008e6 100644
> --- a/drivers/mfd/mc13xxx-core.c
> +++ b/drivers/mfd/mc13xxx-core.c
> @@ -202,19 +202,19 @@ static void mc34708_print_revision(struct mc13xxx *mc13xxx, u32 revision)
> }
>
> /* These are only exported for mc13xxx-i2c and mc13xxx-spi */
> -struct mc13xxx_variant mc13xxx_variant_mc13783 = {
> +const struct mc13xxx_variant mc13xxx_variant_mc13783 = {
> .name = "mc13783",
> .print_revision = mc13xxx_print_revision,
> };
> EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13783);
>
> -struct mc13xxx_variant mc13xxx_variant_mc13892 = {
> +const struct mc13xxx_variant mc13xxx_variant_mc13892 = {
> .name = "mc13892",
> .print_revision = mc13xxx_print_revision,
> };
> EXPORT_SYMBOL_GPL(mc13xxx_variant_mc13892);
>
> -struct mc13xxx_variant mc13xxx_variant_mc34708 = {
> +const struct mc13xxx_variant mc13xxx_variant_mc34708 = {
> .name = "mc34708",
> .print_revision = mc34708_print_revision,
> };
> diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
> index 67e4c9a..3c00ccb 100644
> --- a/drivers/mfd/mc13xxx-i2c.c
> +++ b/drivers/mfd/mc13xxx-i2c.c
> @@ -82,7 +82,7 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
> of_match_device(mc13xxx_dt_ids, &client->dev);
> mc13xxx->variant = of_id->data;
> } else {
> - mc13xxx->variant = (void *)id->driver_data;
> + mc13xxx->variant = (const struct mc13xxx_variant *)id->driver_data;
Is this change required?
> }
>
> return mc13xxx_common_init(&client->dev);
> diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
> index cbc1e5e..6100025 100644
> --- a/drivers/mfd/mc13xxx-spi.c
> +++ b/drivers/mfd/mc13xxx-spi.c
> @@ -162,7 +162,7 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
> } else {
> const struct spi_device_id *id_entry = spi_get_device_id(spi);
>
> - mc13xxx->variant = (void *)id_entry->driver_data;
> + mc13xxx->variant = (const struct mc13xxx_variant *)id_entry->driver_data;
Same here?
> }
>
> return mc13xxx_common_init(&spi->dev);
> diff --git a/drivers/mfd/mc13xxx.h b/drivers/mfd/mc13xxx.h
> index 33677d1..6d7fce5 100644
> --- a/drivers/mfd/mc13xxx.h
> +++ b/drivers/mfd/mc13xxx.h
> @@ -24,7 +24,7 @@ struct mc13xxx_variant {
> void (*print_revision)(struct mc13xxx *mc13xxx, u32 revision);
> };
>
> -extern struct mc13xxx_variant
> +extern const struct mc13xxx_variant
> mc13xxx_variant_mc13783,
> mc13xxx_variant_mc13892,
> mc13xxx_variant_mc34708;
I haven't seen this formatting before.
Can you take the opportunity to write these out separately?
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference
2016-08-16 8:15 ` [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference LABBE Corentin
@ 2016-08-31 9:23 ` Lee Jones
0 siblings, 0 replies; 4+ messages in thread
From: Lee Jones @ 2016-08-31 9:23 UTC (permalink / raw)
To: LABBE Corentin; +Cc: linux-kernel
On Tue, 16 Aug 2016, LABBE Corentin wrote:
> of_match_device could return NULL, and so cause a NULL pointer
> dereference later.
> For fixing this problem, we use of_device_get_match_data(), this will
> simplify the code a little by using a standard function for
> getting the match data.
>
> Reported-by: coverity (CID 986513)
> Reported-by: coverity (CID 986514)
> Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com>
Can you change your name to be "[A-Z][a-z]*"?
> ---
> drivers/mfd/mc13xxx-i2c.c | 4 +---
> drivers/mfd/mc13xxx-spi.c | 5 +----
> 2 files changed, 2 insertions(+), 7 deletions(-)
For the patch:
Acked-by: Lee Jones <lee.jones@linaro.org>
> diff --git a/drivers/mfd/mc13xxx-i2c.c b/drivers/mfd/mc13xxx-i2c.c
> index 3c00ccb..8ad7593 100644
> --- a/drivers/mfd/mc13xxx-i2c.c
> +++ b/drivers/mfd/mc13xxx-i2c.c
> @@ -78,9 +78,7 @@ static int mc13xxx_i2c_probe(struct i2c_client *client,
> }
>
> if (client->dev.of_node) {
> - const struct of_device_id *of_id =
> - of_match_device(mc13xxx_dt_ids, &client->dev);
> - mc13xxx->variant = of_id->data;
> + mc13xxx->variant = of_device_get_match_data(&client->dev);
> } else {
> mc13xxx->variant = (const struct mc13xxx_variant *)id->driver_data;
> }
> diff --git a/drivers/mfd/mc13xxx-spi.c b/drivers/mfd/mc13xxx-spi.c
> index 6100025..3b4f5ba 100644
> --- a/drivers/mfd/mc13xxx-spi.c
> +++ b/drivers/mfd/mc13xxx-spi.c
> @@ -155,10 +155,7 @@ static int mc13xxx_spi_probe(struct spi_device *spi)
> }
>
> if (spi->dev.of_node) {
> - const struct of_device_id *of_id =
> - of_match_device(mc13xxx_dt_ids, &spi->dev);
> -
> - mc13xxx->variant = of_id->data;
> + mc13xxx->variant = of_device_get_match_data(&spi->dev);
> } else {
> const struct spi_device_id *id_entry = spi_get_device_id(spi);
>
--
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-31 9:23 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-16 8:15 [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant LABBE Corentin
2016-08-16 8:15 ` [PATCH 2/2] mfd: mc13xxx: fix a possible NULL dereference LABBE Corentin
2016-08-31 9:23 ` Lee Jones
2016-08-31 9:20 ` [PATCH 1/2] mfd: mc13xxx: constify mc13xxx_variant Lee Jones
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).