diff mbox

Video: fbdev - Fix possible NULL derefrence.

Message ID 1485752458-29955-1-git-send-email-shailendra.v@samsung.com (mailing list archive)
State New, archived
Headers show

Commit Message

shailendra.v@samsung.com Jan. 30, 2017, 5 a.m. UTC
of_device_get_match_data could return NULL, and so can cause
a NULL pointer dereference later.

Signed-off-by: Shailendra Verma <shailendra.v@samsung.com>
---
 drivers/video/fbdev/ssd1307fb.c |    4 ++++
 1 file changed, 4 insertions(+)
diff mbox

Patch

diff --git a/drivers/video/fbdev/ssd1307fb.c b/drivers/video/fbdev/ssd1307fb.c
index 2925d5c..bdf7d80 100644
--- a/drivers/video/fbdev/ssd1307fb.c
+++ b/drivers/video/fbdev/ssd1307fb.c
@@ -560,6 +560,10 @@  static int ssd1307fb_probe(struct i2c_client *client,
 	par->client = client;
 
 	par->device_info = of_device_get_match_data(&client->dev);
+	if (!par->device_info) {
+		dev_err(&client->dev, "no device match found\n");
+		return -ENODEV;
+	}
 
 	par->reset = of_get_named_gpio(client->dev.of_node,
 					 "reset-gpios", 0);