Message ID | 20241114072820.3071-1-hanchunchao@inspur.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | clk: clk-apple-nco: Add NULL check in applnco_probe | expand |
Thanks. Reviewed-by: Martin Povišer <povik+lin@cutebit.org> Martin > On 14. 11. 2024, at 8:28, Charles Han <hanchunchao@inspur.com> wrote: > > Add NULL check in applnco_probe, to handle kernel NULL pointer > dereference error. > > Fixes: 6641057d5dba ("clk: clk-apple-nco: Add driver for Apple NCO") > Signed-off-by: Charles Han <hanchunchao@inspur.com> > --- > drivers/clk/clk-apple-nco.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/drivers/clk/clk-apple-nco.c b/drivers/clk/clk-apple-nco.c > index 39472a51530a..457a48d48941 100644 > --- a/drivers/clk/clk-apple-nco.c > +++ b/drivers/clk/clk-apple-nco.c > @@ -297,6 +297,9 @@ static int applnco_probe(struct platform_device *pdev) > memset(&init, 0, sizeof(init)); > init.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, > "%s-%d", np->name, i); > + if (!init.name) > + return -ENOMEM; > + > init.ops = &applnco_ops; > init.parent_data = &pdata; > init.num_parents = 1; > -- > 2.31.1 > >
diff --git a/drivers/clk/clk-apple-nco.c b/drivers/clk/clk-apple-nco.c index 39472a51530a..457a48d48941 100644 --- a/drivers/clk/clk-apple-nco.c +++ b/drivers/clk/clk-apple-nco.c @@ -297,6 +297,9 @@ static int applnco_probe(struct platform_device *pdev) memset(&init, 0, sizeof(init)); init.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s-%d", np->name, i); + if (!init.name) + return -ENOMEM; + init.ops = &applnco_ops; init.parent_data = &pdata; init.num_parents = 1;
Add NULL check in applnco_probe, to handle kernel NULL pointer dereference error. Fixes: 6641057d5dba ("clk: clk-apple-nco: Add driver for Apple NCO") Signed-off-by: Charles Han <hanchunchao@inspur.com> --- drivers/clk/clk-apple-nco.c | 3 +++ 1 file changed, 3 insertions(+)