From: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Date: Wed, 23 May 2012 13:54:44 +0000 (+0200)
Subject: Staging: ipack/bridges/tpci200: check if the remove function is available
X-Git-Tag: firefly_0821_release~3680^2~2356^2~910
X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=786d986ea25632e3d8e7ad5ac2780861ff2b654f;p=firefly-linux-kernel-4.4.55.git

Staging: ipack/bridges/tpci200: check if the remove function is available

To avoid a dereference of a NULL pointer, the availability of the function is
checked before its use.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---

diff --git a/drivers/staging/ipack/bridges/tpci200.c b/drivers/staging/ipack/bridges/tpci200.c
index 0c2a50a1ec00..ee26d9a7e370 100644
--- a/drivers/staging/ipack/bridges/tpci200.c
+++ b/drivers/staging/ipack/bridges/tpci200.c
@@ -764,6 +764,8 @@ out:
 static void tpci200_slot_remove(struct tpci200_slot *slot)
 {
 	if ((slot->dev == NULL) ||
+	    (slot->dev->driver == NULL) ||
+	    (slot->dev->driver->ops == NULL) ||
 	    (slot->dev->driver->ops->remove == NULL))
 		return;