diff options
| author | Huacai Chen <chenhc@lemote.com> | 2014-11-27 08:05:34 -0500 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2014-11-30 00:11:16 -0500 |
| commit | 28603d13997e2ef47f18589cc9a44553aad49c86 (patch) | |
| tree | 9f4b995f9f0f232f43346750e125ee462910a494 /drivers/net/ethernet/stmicro | |
| parent | 4d6a949c62f123569fb355b6ec7f314b76f93735 (diff) | |
stmmac: platform: Move plat_dat checking earlier
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'
V2: Fix coding style.
Signed-off-by: Huacai Chen <chenhc@lemote.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/stmicro')
| -rw-r--r-- | drivers/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 5b0da3986216..58a1a0a423d4 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) | |||
| 265 | 265 | ||
| 266 | plat_dat = dev_get_platdata(&pdev->dev); | 266 | plat_dat = dev_get_platdata(&pdev->dev); |
| 267 | 267 | ||
| 268 | if (!plat_dat) | ||
| 269 | plat_dat = devm_kzalloc(&pdev->dev, | ||
| 270 | sizeof(struct plat_stmmacenet_data), | ||
| 271 | GFP_KERNEL); | ||
| 272 | if (!plat_dat) { | ||
| 273 | pr_err("%s: ERROR: no memory", __func__); | ||
| 274 | return -ENOMEM; | ||
| 275 | } | ||
| 276 | |||
| 268 | /* Set default value for multicast hash bins */ | 277 | /* Set default value for multicast hash bins */ |
| 269 | plat_dat->multicast_filter_bins = HASH_TABLE_SIZE; | 278 | plat_dat->multicast_filter_bins = HASH_TABLE_SIZE; |
| 270 | 279 | ||
| @@ -272,15 +281,6 @@ static int stmmac_pltfr_probe(struct platform_device *pdev) | |||
| 272 | plat_dat->unicast_filter_entries = 1; | 281 | plat_dat->unicast_filter_entries = 1; |
| 273 | 282 | ||
| 274 | if (pdev->dev.of_node) { | 283 | if (pdev->dev.of_node) { |
| 275 | if (!plat_dat) | ||
| 276 | plat_dat = devm_kzalloc(&pdev->dev, | ||
| 277 | sizeof(struct plat_stmmacenet_data), | ||
| 278 | GFP_KERNEL); | ||
| 279 | if (!plat_dat) { | ||
| 280 | pr_err("%s: ERROR: no memory", __func__); | ||
| 281 | return -ENOMEM; | ||
| 282 | } | ||
| 283 | |||
| 284 | ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); | 284 | ret = stmmac_probe_config_dt(pdev, plat_dat, &mac); |
| 285 | if (ret) { | 285 | if (ret) { |
| 286 | pr_err("%s: main dt probe failed", __func__); | 286 | pr_err("%s: main dt probe failed", __func__); |
