soc: qcom: subsystem_restart: Add checks to verify validity of a device
Extra checks are added to ensure a subsystem device is valid before accessing any of its fields. Change-Id: Ia8e3dced005485b1edb5d6ccf9429f90d31fa613 Signed-off-by: Anant Goel <anantg@codeaurora.org>
This commit is contained in:
parent
53c73b7190
commit
a6672f6af9
1 changed files with 12 additions and 2 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* Copyright (c) 2011-2017, The Linux Foundation. All rights reserved.
|
/* Copyright (c) 2011-2018, 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
|
||||||
|
@ -1083,7 +1083,7 @@ int subsystem_restart_dev(struct subsys_device *dev)
|
||||||
{
|
{
|
||||||
const char *name;
|
const char *name;
|
||||||
|
|
||||||
if (!get_device(&dev->dev))
|
if ((!dev) || !get_device(&dev->dev))
|
||||||
return -ENODEV;
|
return -ENODEV;
|
||||||
|
|
||||||
if (!try_module_get(dev->owner)) {
|
if (!try_module_get(dev->owner)) {
|
||||||
|
@ -1177,11 +1177,21 @@ EXPORT_SYMBOL(subsystem_crashed);
|
||||||
void subsys_set_crash_status(struct subsys_device *dev,
|
void subsys_set_crash_status(struct subsys_device *dev,
|
||||||
enum crash_status crashed)
|
enum crash_status crashed)
|
||||||
{
|
{
|
||||||
|
if (!dev) {
|
||||||
|
pr_err("Invalid subsystem device\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
dev->crashed = crashed;
|
dev->crashed = crashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum crash_status subsys_get_crash_status(struct subsys_device *dev)
|
enum crash_status subsys_get_crash_status(struct subsys_device *dev)
|
||||||
{
|
{
|
||||||
|
if (!dev) {
|
||||||
|
pr_err("Invalid subsystem device\n");
|
||||||
|
return CRASH_STATUS_NO_CRASH;
|
||||||
|
}
|
||||||
|
|
||||||
return dev->crashed;
|
return dev->crashed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue