From: Corey Minyard <cminy...@mvista.com>

Just an added safety check.

Signed-off-by: Corey Minyard <cminy...@mvista.com>
---
 drivers/char/ipmi/ipmi_msghandler.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/char/ipmi/ipmi_msghandler.c 
b/drivers/char/ipmi/ipmi_msghandler.c
index 461ca4f..ab1f48d 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2512,9 +2512,11 @@ static const struct device_type bmc_device_type = {
 static int __find_bmc_guid(struct device *dev, void *data)
 {
        unsigned char *id = data;
-       struct bmc_device *bmc = to_bmc_device(dev);
 
-       return memcmp(bmc->guid, id, 16) == 0;
+       if (dev->type != &bmc_device_type)
+               return 0;
+
+       return memcmp(to_bmc_device(dev)->guid, id, 16) == 0;
 }
 
 static struct bmc_device *ipmi_find_bmc_guid(struct device_driver *drv,
@@ -2537,8 +2539,12 @@ struct prod_dev_id {
 static int __find_bmc_prod_dev_id(struct device *dev, void *data)
 {
        struct prod_dev_id *id = data;
-       struct bmc_device *bmc = to_bmc_device(dev);
+       struct bmc_device *bmc;
+
+       if (dev->type != &bmc_device_type)
+               return 0;
 
+       bmc = to_bmc_device(dev);
        return (bmc->id.product_id == id->product_id
                && bmc->id.device_id == id->device_id);
 }
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Openipmi-developer mailing list
Openipmi-developer@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openipmi-developer

Reply via email to