mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-06-29 18:11:20 +00:00
powerpc/fadump: use kstrtoint to handle sysfs store
Currently sysfs store handlers in fadump use if buf[0] == 'char'. This means input "100foo" is interpreted as '1' and "01" as '0'. Change to kstrtoint so leading zeroes and the like is handled in expected way. Signed-off-by: Michal Suchanek <msuchanek@suse.de> Acked-by: Hari Bathini <hbathini@linux.vnet.ibm.com> Signed-off-by: Michal Suchanek <a class="moz-txt-link-rfc2396E" href="mailto:msuchanek@suse.de"><msuchanek@suse.de></a></pre> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
This commit is contained in:
parent
6c44741d75
commit
dcdc46794b
1 changed files with 13 additions and 4 deletions
|
@ -1270,10 +1270,15 @@ static ssize_t fadump_release_memory_store(struct kobject *kobj,
|
||||||
struct kobj_attribute *attr,
|
struct kobj_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
|
int input = -1;
|
||||||
|
|
||||||
if (!fw_dump.dump_active)
|
if (!fw_dump.dump_active)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
if (buf[0] == '1') {
|
if (kstrtoint(buf, 0, &input))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
if (input == 1) {
|
||||||
/*
|
/*
|
||||||
* Take away the '/proc/vmcore'. We are releasing the dump
|
* Take away the '/proc/vmcore'. We are releasing the dump
|
||||||
* memory, hence it will not be valid anymore.
|
* memory, hence it will not be valid anymore.
|
||||||
|
@ -1307,21 +1312,25 @@ static ssize_t fadump_register_store(struct kobject *kobj,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int input = -1;
|
||||||
|
|
||||||
if (!fw_dump.fadump_enabled || fdm_active)
|
if (!fw_dump.fadump_enabled || fdm_active)
|
||||||
return -EPERM;
|
return -EPERM;
|
||||||
|
|
||||||
|
if (kstrtoint(buf, 0, &input))
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
mutex_lock(&fadump_mutex);
|
mutex_lock(&fadump_mutex);
|
||||||
|
|
||||||
switch (buf[0]) {
|
switch (input) {
|
||||||
case '0':
|
case 0:
|
||||||
if (fw_dump.dump_registered == 0) {
|
if (fw_dump.dump_registered == 0) {
|
||||||
goto unlock_out;
|
goto unlock_out;
|
||||||
}
|
}
|
||||||
/* Un-register Firmware-assisted dump */
|
/* Un-register Firmware-assisted dump */
|
||||||
fadump_unregister_dump(&fdm);
|
fadump_unregister_dump(&fdm);
|
||||||
break;
|
break;
|
||||||
case '1':
|
case 1:
|
||||||
if (fw_dump.dump_registered == 1) {
|
if (fw_dump.dump_registered == 1) {
|
||||||
ret = -EEXIST;
|
ret = -EEXIST;
|
||||||
goto unlock_out;
|
goto unlock_out;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue