tegra-hsp: fix a missing-check bug in tegra_hsp_doorbell_create()
Subsystems (2)
PATCH 1/1 tegra-hsp: fix a missing-check bug in tegra_hsp_doorbell_create()
In tegra_hsp_doorbell_create(), 'db->name' is allocated by devm_kstrdup_const(). It returns NULL when fails. So 'db->name' should be checked.
---
drivers/mailbox/tegra-hsp.c +2 -0
@@ -292,6 +292,8 @@ tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, db->channel.hsp = hsp; db->name =devm_kstrdup_const (hsp->dev, name,GFP_KERNEL ); +if (!db->name) +return ERR_PTR (-ENOMEM ); db->master = master; db->index = index;
---
Quoted 11 lines · Gen Zhang
In
tegra_hsp_doorbell_create(), 'db->name' is allocated bydevm_kstrdup_const(). It returns NULL when fails. So 'db->name' should be checked.Signed-off-by Gen Zhang <[email protected]>---
drivers/mailbox/tegra-hsp.c +0
-0
drivers/mailbox/tegra-hsp.c tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, · line 296
Quoted 5 lines
drivers/mailbox/tegra-hsp.c +2
-0@@ -292,6 +292,8 @@ tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, db->channel.hsp = hsp; db->name =devm_kstrdup_const (hsp->dev, name,GFP_KERNEL ); +if (!db->name) +return ERR_PTR (-ENOMEM );
I don't think this could ever happen, since name is always from .rodata and hence devm_kstrdup_const() never returns NULL. But formally this is correct, so:
Quoted 22 lines · Thierry Reding
Quoted 11 lines · Gen Zhang
In
tegra_hsp_doorbell_create(), 'db->name' is allocated bydevm_kstrdup_const(). It returns NULL when fails. So 'db->name' should be checked.Signed-off-by Gen Zhang <[email protected]>---
drivers/mailbox/tegra-hsp.c +0
-0drivers/mailbox/tegra-hsp.c tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, · line 296
Quoted 5 lines
drivers/mailbox/tegra-hsp.c +2
-0@@ -292,6 +292,8 @@ tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name, db->channel.hsp = hsp; db->name =devm_kstrdup_const (hsp->dev, name,GFP_KERNEL ); +if (!db->name) +return ERR_PTR (-ENOMEM );I don't think this could ever happen, since name is always from .rodata and hence
devm_kstrdup_const()never returns NULL. But formally this is correct, so:
Quoted 1 line
Acked-by Thierry Reding <[email protected]>
Thanks for your reply, Thierry.
Thanks
Gen