Merge "esoc: Fix potential NULL pointer dereferences"
This commit is contained in:
commit
37e30d7fbd
4 changed files with 30 additions and 20 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2014-2015, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2014-2015, 2017, The Linux Foundation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -434,11 +434,12 @@ static irqreturn_t mdm_status_change(int irq, void *dev_id)
|
||||||
{
|
{
|
||||||
int value;
|
int value;
|
||||||
struct esoc_clink *esoc;
|
struct esoc_clink *esoc;
|
||||||
|
struct device *dev;
|
||||||
struct mdm_ctrl *mdm = (struct mdm_ctrl *)dev_id;
|
struct mdm_ctrl *mdm = (struct mdm_ctrl *)dev_id;
|
||||||
struct device *dev = mdm->dev;
|
|
||||||
|
|
||||||
if (!mdm)
|
if (!mdm)
|
||||||
return IRQ_HANDLED;
|
return IRQ_HANDLED;
|
||||||
|
dev = mdm->dev;
|
||||||
esoc = mdm->esoc;
|
esoc = mdm->esoc;
|
||||||
value = gpio_get_value(MDM_GPIO(mdm, MDM2AP_STATUS));
|
value = gpio_get_value(MDM_GPIO(mdm, MDM2AP_STATUS));
|
||||||
if (value == 0 && mdm->ready) {
|
if (value == 0 && mdm->ready) {
|
||||||
|
@ -499,7 +500,7 @@ static void mdm_configure_debug(struct mdm_ctrl *mdm)
|
||||||
struct device_node *node = mdm->dev->of_node;
|
struct device_node *node = mdm->dev->of_node;
|
||||||
|
|
||||||
addr = of_iomap(node, 0);
|
addr = of_iomap(node, 0);
|
||||||
if (IS_ERR(addr)) {
|
if (IS_ERR_OR_NULL(addr)) {
|
||||||
dev_err(mdm->dev, "failed to get debug base addres\n");
|
dev_err(mdm->dev, "failed to get debug base addres\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -508,7 +509,7 @@ static void mdm_configure_debug(struct mdm_ctrl *mdm)
|
||||||
if (val == MDM_DBG_MODE) {
|
if (val == MDM_DBG_MODE) {
|
||||||
mdm->dbg_mode = true;
|
mdm->dbg_mode = true;
|
||||||
mdm->cti = coresight_cti_get(MDM_CTI_NAME);
|
mdm->cti = coresight_cti_get(MDM_CTI_NAME);
|
||||||
if (IS_ERR(mdm->cti)) {
|
if (IS_ERR_OR_NULL(mdm->cti)) {
|
||||||
dev_err(mdm->dev, "unable to get cti handle\n");
|
dev_err(mdm->dev, "unable to get cti handle\n");
|
||||||
goto cti_get_err;
|
goto cti_get_err;
|
||||||
}
|
}
|
||||||
|
@ -743,7 +744,7 @@ static int mdm9x25_setup_hw(struct mdm_ctrl *mdm,
|
||||||
mdm->dev = &pdev->dev;
|
mdm->dev = &pdev->dev;
|
||||||
mdm->pon_ops = pon_ops;
|
mdm->pon_ops = pon_ops;
|
||||||
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
||||||
if (IS_ERR(esoc)) {
|
if (IS_ERR_OR_NULL(esoc)) {
|
||||||
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
||||||
return PTR_ERR(esoc);
|
return PTR_ERR(esoc);
|
||||||
}
|
}
|
||||||
|
@ -813,7 +814,7 @@ static int mdm9x35_setup_hw(struct mdm_ctrl *mdm,
|
||||||
mdm->pon_ops = pon_ops;
|
mdm->pon_ops = pon_ops;
|
||||||
node = pdev->dev.of_node;
|
node = pdev->dev.of_node;
|
||||||
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
||||||
if (IS_ERR(esoc)) {
|
if (IS_ERR_OR_NULL(esoc)) {
|
||||||
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
||||||
return PTR_ERR(esoc);
|
return PTR_ERR(esoc);
|
||||||
}
|
}
|
||||||
|
@ -901,7 +902,7 @@ static int mdm9x55_setup_hw(struct mdm_ctrl *mdm,
|
||||||
mdm->pon_ops = pon_ops;
|
mdm->pon_ops = pon_ops;
|
||||||
node = pdev->dev.of_node;
|
node = pdev->dev.of_node;
|
||||||
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
esoc = devm_kzalloc(mdm->dev, sizeof(*esoc), GFP_KERNEL);
|
||||||
if (IS_ERR(esoc)) {
|
if (IS_ERR_OR_NULL(esoc)) {
|
||||||
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
dev_err(mdm->dev, "cannot allocate esoc device\n");
|
||||||
return PTR_ERR(esoc);
|
return PTR_ERR(esoc);
|
||||||
}
|
}
|
||||||
|
@ -1001,11 +1002,11 @@ static int mdm_probe(struct platform_device *pdev)
|
||||||
struct mdm_ctrl *mdm;
|
struct mdm_ctrl *mdm;
|
||||||
|
|
||||||
match = of_match_node(mdm_dt_match, node);
|
match = of_match_node(mdm_dt_match, node);
|
||||||
if (IS_ERR(match))
|
if (IS_ERR_OR_NULL(match))
|
||||||
return PTR_ERR(match);
|
return PTR_ERR(match);
|
||||||
mdm_ops = match->data;
|
mdm_ops = match->data;
|
||||||
mdm = devm_kzalloc(&pdev->dev, sizeof(*mdm), GFP_KERNEL);
|
mdm = devm_kzalloc(&pdev->dev, sizeof(*mdm), GFP_KERNEL);
|
||||||
if (IS_ERR(mdm))
|
if (IS_ERR_OR_NULL(mdm))
|
||||||
return PTR_ERR(mdm);
|
return PTR_ERR(mdm);
|
||||||
return mdm_ops->config_hw(mdm, mdm_ops, pdev);
|
return mdm_ops->config_hw(mdm, mdm_ops, pdev);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2013-2015, 2017, The Linux Foundation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -230,7 +230,7 @@ int esoc_ssr_probe(struct esoc_clink *esoc_clink, struct esoc_drv *drv)
|
||||||
struct esoc_eng *esoc_eng;
|
struct esoc_eng *esoc_eng;
|
||||||
|
|
||||||
mdm_drv = devm_kzalloc(&esoc_clink->dev, sizeof(*mdm_drv), GFP_KERNEL);
|
mdm_drv = devm_kzalloc(&esoc_clink->dev, sizeof(*mdm_drv), GFP_KERNEL);
|
||||||
if (IS_ERR(mdm_drv))
|
if (IS_ERR_OR_NULL(mdm_drv))
|
||||||
return PTR_ERR(mdm_drv);
|
return PTR_ERR(mdm_drv);
|
||||||
esoc_eng = &mdm_drv->cmd_eng;
|
esoc_eng = &mdm_drv->cmd_eng;
|
||||||
esoc_eng->handle_clink_evt = mdm_handle_clink_evt;
|
esoc_eng->handle_clink_evt = mdm_handle_clink_evt;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2013-2015, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2013-2015, 2017, The Linux Foundation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -129,7 +129,7 @@ struct esoc_clink *get_esoc_clink(int id)
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
|
|
||||||
dev = bus_find_device(&esoc_bus_type, NULL, &id, esoc_clink_match_id);
|
dev = bus_find_device(&esoc_bus_type, NULL, &id, esoc_clink_match_id);
|
||||||
if (IS_ERR(dev))
|
if (IS_ERR_OR_NULL(dev))
|
||||||
return NULL;
|
return NULL;
|
||||||
esoc_clink = to_esoc_clink(dev);
|
esoc_clink = to_esoc_clink(dev);
|
||||||
return esoc_clink;
|
return esoc_clink;
|
||||||
|
@ -143,7 +143,7 @@ struct esoc_clink *get_esoc_clink_by_node(struct device_node *node)
|
||||||
|
|
||||||
dev = bus_find_device(&esoc_bus_type, NULL, node,
|
dev = bus_find_device(&esoc_bus_type, NULL, node,
|
||||||
esoc_clink_match_node);
|
esoc_clink_match_node);
|
||||||
if (IS_ERR(dev))
|
if (IS_ERR_OR_NULL(dev))
|
||||||
return NULL;
|
return NULL;
|
||||||
esoc_clink = to_esoc_clink(dev);
|
esoc_clink = to_esoc_clink(dev);
|
||||||
return esoc_clink;
|
return esoc_clink;
|
||||||
|
@ -175,14 +175,14 @@ int esoc_clink_register_ssr(struct esoc_clink *esoc_clink)
|
||||||
|
|
||||||
len = strlen("esoc") + sizeof(esoc_clink->id);
|
len = strlen("esoc") + sizeof(esoc_clink->id);
|
||||||
subsys_name = kzalloc(len, GFP_KERNEL);
|
subsys_name = kzalloc(len, GFP_KERNEL);
|
||||||
if (IS_ERR(subsys_name))
|
if (IS_ERR_OR_NULL(subsys_name))
|
||||||
return PTR_ERR(subsys_name);
|
return PTR_ERR(subsys_name);
|
||||||
snprintf(subsys_name, len, "esoc%d", esoc_clink->id);
|
snprintf(subsys_name, len, "esoc%d", esoc_clink->id);
|
||||||
esoc_clink->subsys.name = subsys_name;
|
esoc_clink->subsys.name = subsys_name;
|
||||||
esoc_clink->dev.of_node = esoc_clink->np;
|
esoc_clink->dev.of_node = esoc_clink->np;
|
||||||
esoc_clink->subsys.dev = &esoc_clink->dev;
|
esoc_clink->subsys.dev = &esoc_clink->dev;
|
||||||
esoc_clink->subsys_dev = subsys_register(&esoc_clink->subsys);
|
esoc_clink->subsys_dev = subsys_register(&esoc_clink->subsys);
|
||||||
if (IS_ERR(esoc_clink->subsys_dev)) {
|
if (IS_ERR_OR_NULL(esoc_clink->subsys_dev)) {
|
||||||
dev_err(&esoc_clink->dev, "failed to register ssr node\n");
|
dev_err(&esoc_clink->dev, "failed to register ssr node\n");
|
||||||
ret = PTR_ERR(esoc_clink->subsys_dev);
|
ret = PTR_ERR(esoc_clink->subsys_dev);
|
||||||
goto subsys_err;
|
goto subsys_err;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2013-2014, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2013-2014, 2017, The Linux Foundation. All rights reserved.
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License version 2 and
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -260,7 +260,16 @@ static int esoc_dev_open(struct inode *inode, struct file *file)
|
||||||
unsigned int minor = iminor(inode);
|
unsigned int minor = iminor(inode);
|
||||||
|
|
||||||
esoc_udev = esoc_udev_get_by_minor(minor);
|
esoc_udev = esoc_udev_get_by_minor(minor);
|
||||||
|
if (!esoc_udev) {
|
||||||
|
pr_err("failed to get udev\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
esoc_clink = get_esoc_clink(esoc_udev->clink->id);
|
esoc_clink = get_esoc_clink(esoc_udev->clink->id);
|
||||||
|
if (!esoc_clink) {
|
||||||
|
pr_err("failed to get clink\n");
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
uhandle = kzalloc(sizeof(*uhandle), GFP_KERNEL);
|
uhandle = kzalloc(sizeof(*uhandle), GFP_KERNEL);
|
||||||
if (!uhandle) {
|
if (!uhandle) {
|
||||||
|
@ -306,12 +315,12 @@ int esoc_clink_add_device(struct device *dev, void *dummy)
|
||||||
struct esoc_clink *esoc_clink = to_esoc_clink(dev);
|
struct esoc_clink *esoc_clink = to_esoc_clink(dev);
|
||||||
|
|
||||||
esoc_udev = get_free_esoc_udev(esoc_clink);
|
esoc_udev = get_free_esoc_udev(esoc_clink);
|
||||||
if (IS_ERR(esoc_udev))
|
if (IS_ERR_OR_NULL(esoc_udev))
|
||||||
return PTR_ERR(esoc_udev);
|
return PTR_ERR(esoc_udev);
|
||||||
esoc_udev->dev = device_create(esoc_class, &esoc_clink->dev,
|
esoc_udev->dev = device_create(esoc_class, &esoc_clink->dev,
|
||||||
MKDEV(esoc_major, esoc_clink->id),
|
MKDEV(esoc_major, esoc_clink->id),
|
||||||
esoc_clink, "esoc-%d", esoc_clink->id);
|
esoc_clink, "esoc-%d", esoc_clink->id);
|
||||||
if (IS_ERR(esoc_udev->dev)) {
|
if (IS_ERR_OR_NULL(esoc_udev->dev)) {
|
||||||
pr_err("failed to create user device\n");
|
pr_err("failed to create user device\n");
|
||||||
goto dev_err;
|
goto dev_err;
|
||||||
}
|
}
|
||||||
|
@ -358,7 +367,7 @@ int __init esoc_dev_init(void)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
esoc_class = class_create(THIS_MODULE, "esoc-dev");
|
esoc_class = class_create(THIS_MODULE, "esoc-dev");
|
||||||
if (IS_ERR(esoc_class)) {
|
if (IS_ERR_OR_NULL(esoc_class)) {
|
||||||
pr_err("coudn't create class");
|
pr_err("coudn't create class");
|
||||||
return PTR_ERR(esoc_class);
|
return PTR_ERR(esoc_class);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue