Skip to content

Commit 9d01391

Browse files
marcusfolkessonJiri Kosina
authored andcommitted
HID: hid-sensor-custom: set fixed size for custom attributes
This is no bugfix (so no Fixes: tag is necessary) as it is taken care of in hid_sensor_custom_add_attributes(). The motivation for this patch is that: hid_sensor_custom_field.attr_name and hid_sensor_custom_field.attrs has the size of HID_CUSTOM_TOTAL_ATTRS and used in same context. We compare against HID_CUSTOM_TOTAL_ATTRS when looping through hid_custom_attrs. We will silent the smatch error: hid_sensor_custom_add_attributes() error: buffer overflow 'hid_custom_attrs' 8 <= 10 Signed-off-by: Marcus Folkesson <[email protected]> Acked-by: Jonathan Cameron <[email protected]> Signed-off-by: Jiri Kosina <[email protected]>
1 parent 9861a25 commit 9d01391

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/hid/hid-sensor-custom.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ struct hid_sensor_sample {
6262
u32 raw_len;
6363
} __packed;
6464

65-
static struct attribute hid_custom_attrs[] = {
65+
static struct attribute hid_custom_attrs[HID_CUSTOM_TOTAL_ATTRS] = {
6666
{.name = "name", .mode = S_IRUGO},
6767
{.name = "units", .mode = S_IRUGO},
6868
{.name = "unit-expo", .mode = S_IRUGO},

0 commit comments

Comments
 (0)