fpga: altera-hps2fpga: add NULL check on of_match_device() return value
PATCH 1/1 fpga: altera-hps2fpga: add NULL check on of_match_device() return value
Check return value from call to of_match_device()
in order to prevent a NULL pointer dereference.
In case of NULL print error message and return -ENODEV
--- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+)
drivers/fpga/altera-hps2fpga.c +5 -0
@@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)int ret; of_id =of_match_device (altera_fpga_of_match, dev); +if (!of_id) { +dev_err (dev,"failed to match device\n" ); +return -ENODEV ; + } + priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset =of_reset_control_get_by_index (dev->of_node,0 );
Signature · 1 line
2.5.0
On Fri, Jul 7, 2017 at 1:22 AM, Gustavo A. R. Silva
Hi Gustavo,
Thanks for the fix!
Alan
Quoted 6 lines · <[email protected]> wrote:
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>
Quoted 23 lines
--- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/fpga/altera-hps2fpga.c +5
-1@@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)int ret; of_id =of_match_device (altera_fpga_of_match, dev); +if (!of_id) { +dev_err (dev,"failed to match device\n" ); +return -ENODEV ; + } + priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset =of_reset_control_get_by_index (dev->of_node,0 ); --2.5.0
Hi Alan,
Quoting Alan Tull <[email protected]>:
Quoted 6 lines
On Fri, Jul 7, 2017 at 1:22 AM, Gustavo A. R. Silva
Hi Gustavo,
Thanks for the fix!
Absolutely, glad to help. :)
Quoted 32 lines
Alan
Quoted 6 lines · <[email protected]> wrote:
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>Acked-by Alan Tull <[email protected]>Quoted 20 lines
--- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/fpga/altera-hps2fpga.c +5
-0@@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)int ret; of_id =of_match_device (altera_fpga_of_match, dev); +if (!of_id) { +dev_err (dev,"failed to match device\n" ); +return -ENODEV ; + } + priv = (struct altera_hps2fpga_data *)of_id->data;
Quoted 4 lines
Quoted 4 lines
priv->bridge_reset = of_reset_control_get_by_index(dev->of_node, 0);--
2.5.0
--
Gustavo A. R. Silva
Quoted 6 lines · Gustavo A. R. Silva
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>
Quoted 23 lines
--- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/fpga/altera-hps2fpga.c +5
-1@@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)int ret; of_id =of_match_device (altera_fpga_of_match, dev); +if (!of_id) { +dev_err (dev,"failed to match device\n" ); +return -ENODEV ; + } + priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset =of_reset_control_get_by_index (dev->of_node,0 ); --2.5.0
Quoted 9 lines · Moritz Fischer
Quoted 6 lines · Gustavo A. R. Silva
Check return value from call to
of_match_device()
in order to prevent a NULL pointer dereference.In case of NULL print error message and return
-ENODEVSigned-off-by Gustavo A. R. Silva <[email protected]>Reviewed-by Moritz Fischer <[email protected]>
Thank you, Moritz.
Quoted 23 lines
Quoted 23 lines
--- drivers/fpga/altera-hps2fpga.c | 5 +++++ 1 file changed, 5 insertions(+)drivers/fpga/altera-hps2fpga.c +5
-1@@ -143,6 +143,11 @@ static int alt_fpga_bridge_probe(struct platform_device *pdev)int ret; of_id =of_match_device (altera_fpga_of_match, dev); +if (!of_id) { +dev_err (dev,"failed to match device\n" ); +return -ENODEV ; + } + priv = (struct altera_hps2fpga_data *)of_id->data; priv->bridge_reset =of_reset_control_get_by_index (dev->of_node,0 ); --2.5.0
Signature · 1 line
Gustavo A. R. Silva