clk: palmas: fix a possible NULL dereference
of_match_device could return NULL, and so cause a NULL pointer dereference later. Even if the probability of this case is very low, fixing it made static analyzers happy. Solving this with of_device_get_match_data made also code simplier. Reported-by: coverity (CID 1324137) Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
This commit is contained in:
parent
93fffbbee1
commit
8d0a69d735
|
@ -241,13 +241,13 @@ static int palmas_clks_probe(struct platform_device *pdev)
|
||||||
struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
|
struct palmas *palmas = dev_get_drvdata(pdev->dev.parent);
|
||||||
struct device_node *node = pdev->dev.of_node;
|
struct device_node *node = pdev->dev.of_node;
|
||||||
const struct palmas_clks_of_match_data *match_data;
|
const struct palmas_clks_of_match_data *match_data;
|
||||||
const struct of_device_id *match;
|
|
||||||
struct palmas_clock_info *cinfo;
|
struct palmas_clock_info *cinfo;
|
||||||
struct clk *clk;
|
struct clk *clk;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
match = of_match_device(palmas_clks_of_match, &pdev->dev);
|
match_data = of_device_get_match_data(&pdev->dev);
|
||||||
match_data = match->data;
|
if (!match_data)
|
||||||
|
return 1;
|
||||||
|
|
||||||
cinfo = devm_kzalloc(&pdev->dev, sizeof(*cinfo), GFP_KERNEL);
|
cinfo = devm_kzalloc(&pdev->dev, sizeof(*cinfo), GFP_KERNEL);
|
||||||
if (!cinfo)
|
if (!cinfo)
|
||||||
|
|
Loading…
Reference in New Issue