* [PATCH] stmmac: platform: Move plat_dat checking earlier
@ 2014-11-27 3:14 Huacai Chen
2014-11-27 12:52 ` Sergei Shtylyov
0 siblings, 1 reply; 2+ messages in thread
From: Huacai Chen @ 2014-11-27 3:14 UTC (permalink / raw)
To: Giuseppe Cavallaro; +Cc: Vince Bridgers, David S. Miller, netdev, Huacai Chen
Original code only check/alloc plat_dat for the CONFIG_OF case, this
patch check/alloc it earlier and unconditionally to avoid kernel build
warnings:
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:275
stmmac_pltfr_probe() warn: variable dereferenced before check 'plat_dat'
Signed-off-by: Huacai Chen <chenhc@lemote.com>
---
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 18 +++++++++---------
1 files changed, 9 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 5b0da39..d254950 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -265,6 +265,15 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
plat_dat = dev_get_platdata(&pdev->dev);
+ if (!plat_dat)
+ plat_dat = devm_kzalloc(&pdev->dev,
+ sizeof(struct plat_stmmacenet_data),
+ GFP_KERNEL);
+ if (!plat_dat) {
+ pr_err("%s: ERROR: no memory", __func__);
+ return -ENOMEM;
+ }
+
/* Set default value for multicast hash bins */
plat_dat->multicast_filter_bins = HASH_TABLE_SIZE;
@@ -272,15 +281,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
plat_dat->unicast_filter_entries = 1;
if (pdev->dev.of_node) {
- if (!plat_dat)
- plat_dat = devm_kzalloc(&pdev->dev,
- sizeof(struct plat_stmmacenet_data),
- GFP_KERNEL);
- if (!plat_dat) {
- pr_err("%s: ERROR: no memory", __func__);
- return -ENOMEM;
- }
-
ret = stmmac_probe_config_dt(pdev, plat_dat, &mac);
if (ret) {
pr_err("%s: main dt probe failed", __func__);
--
1.7.7.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] stmmac: platform: Move plat_dat checking earlier
2014-11-27 3:14 [PATCH] stmmac: platform: Move plat_dat checking earlier Huacai Chen
@ 2014-11-27 12:52 ` Sergei Shtylyov
0 siblings, 0 replies; 2+ messages in thread
From: Sergei Shtylyov @ 2014-11-27 12:52 UTC (permalink / raw)
To: Huacai Chen, Giuseppe Cavallaro; +Cc: Vince Bridgers, David S. Miller, netdev
Hello.
On 11/27/2014 6:14 AM, Huacai Chen wrote:
> Original code only check/alloc plat_dat for the CONFIG_OF case, this
> patch check/alloc it earlier and unconditionally to avoid kernel build
> warnings:
> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:275
> stmmac_pltfr_probe() warn: variable dereferenced before check 'plat_dat'
> Signed-off-by: Huacai Chen <chenhc@lemote.com>
> ---
> .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 18 +++++++++---------
> 1 files changed, 9 insertions(+), 9 deletions(-)
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> index 5b0da39..d254950 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
> @@ -265,6 +265,15 @@ static int stmmac_pltfr_probe(struct platform_device *pdev)
>
> plat_dat = dev_get_platdata(&pdev->dev);
>
> + if (!plat_dat)
> + plat_dat = devm_kzalloc(&pdev->dev,
> + sizeof(struct plat_stmmacenet_data),
> + GFP_KERNEL);
Please start the continuation lines exactly under & on the first line.
[...]
WBR, Sergei
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-11-27 12:52 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-27 3:14 [PATCH] stmmac: platform: Move plat_dat checking earlier Huacai Chen
2014-11-27 12:52 ` Sergei Shtylyov
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).