Skip to content

Commit 2c30678

Browse files
author
Fox Snowpatch
committed
1 parent 182544a commit 2c30678

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

arch/powerpc/platforms/powernv/opal-sensor-groups.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ struct sg_attr {
2323
};
2424

2525
static struct sensor_group {
26-
char name[20];
26+
char *name;
2727
struct attribute_group sg;
2828
struct sg_attr *sgattrs;
2929
} *sgs;
@@ -207,9 +207,12 @@ void __init opal_sensor_groups_init(void)
207207
}
208208

209209
if (!of_property_read_u32(node, "ibm,chip-id", &chipid))
210-
sprintf(sgs[i].name, "%pOFn%d", node, chipid);
210+
sgs[i].name = kasprintf(GFP_KERNEL, "%pOFn%d",
211+
node, chipid);
211212
else
212-
sprintf(sgs[i].name, "%pOFn", node);
213+
sgs[i].name = kasprintf(GFP_KERNEL, "%pOFn", node);
214+
if (!sgs[i].name)
215+
goto out_sgs_sgattrs;
213216

214217
sgs[i].sg.name = sgs[i].name;
215218
if (add_attr_group(ops, len, &sgs[i], sgid)) {
@@ -225,6 +228,7 @@ void __init opal_sensor_groups_init(void)
225228

226229
out_sgs_sgattrs:
227230
while (--i >= 0) {
231+
kfree(sgs[i].name);
228232
kfree(sgs[i].sgattrs);
229233
kfree(sgs[i].sg.attrs);
230234
}

0 commit comments

Comments
 (0)