summaryrefslogtreecommitdiff
path: root/drivers/char
diff options
context:
space:
mode:
authorCorey Minyard <cminyard@mvista.com>2017-09-01 10:46:47 -0500
committerCorey Minyard <cminyard@mvista.com>2017-09-27 16:03:45 -0500
commiteae4a36a6825302cb08c73c91924cade224d96d3 (patch)
treebde3d571058e3559eab099309c6640080348745d /drivers/char
parentf33e4df83e00f629aece2bd3a8d22b533e9d7877 (diff)
ipmi: Check that the device type is BMC when scanning device
Just an added safety check. Signed-off-by: Corey Minyard <cminyard@mvista.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/ipmi/ipmi_msghandler.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c
index 5780fdf6bc7a..efa5581c2f8b 100644
--- a/drivers/char/ipmi/ipmi_msghandler.c
+++ b/drivers/char/ipmi/ipmi_msghandler.c
@@ -2433,9 +2433,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,
@@ -2458,8 +2460,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);
}