Skip to content

Commit 4e27661

Browse files
lategoodbyegregkh
authored andcommitted
staging: vchiq_arm: Get the rid off struct vchiq_2835_state
The whole benefit of this encapsulating struct is questionable. It just stores a flag to signalize the init state of vchiq_arm_state. Beside the fact this flag is set too soon, the access to uninitialized members should be avoided. So initialize vchiq_arm_state properly before assign it directly to vchiq_state. Signed-off-by: Stefan Wahren <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 935cb76 commit 4e27661

File tree

1 file changed

+6
-19
lines changed
  • drivers/staging/vc04_services/interface/vchiq_arm

1 file changed

+6
-19
lines changed

drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,6 @@ struct vchiq_arm_state {
109109
int first_connect;
110110
};
111111

112-
struct vchiq_2835_state {
113-
int inited;
114-
struct vchiq_arm_state arm_state;
115-
};
116-
117112
struct vchiq_pagelist_info {
118113
struct pagelist *pagelist;
119114
size_t pagelist_buffer_size;
@@ -613,29 +608,21 @@ vchiq_arm_init_state(struct vchiq_state *state,
613608
int
614609
vchiq_platform_init_state(struct vchiq_state *state)
615610
{
616-
struct vchiq_2835_state *platform_state;
611+
struct vchiq_arm_state *platform_state;
617612

618-
state->platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
619-
if (!state->platform_state)
613+
platform_state = kzalloc(sizeof(*platform_state), GFP_KERNEL);
614+
if (!platform_state)
620615
return -ENOMEM;
621616

622-
platform_state = (struct vchiq_2835_state *)state->platform_state;
623-
624-
platform_state->inited = 1;
625-
vchiq_arm_init_state(state, &platform_state->arm_state);
617+
vchiq_arm_init_state(state, platform_state);
618+
state->platform_state = (struct opaque_platform_state *)platform_state;
626619

627620
return 0;
628621
}
629622

630623
static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *state)
631624
{
632-
struct vchiq_2835_state *platform_state;
633-
634-
platform_state = (struct vchiq_2835_state *)state->platform_state;
635-
636-
WARN_ON_ONCE(!platform_state->inited);
637-
638-
return &platform_state->arm_state;
625+
return (struct vchiq_arm_state *)state->platform_state;
639626
}
640627

641628
void

0 commit comments

Comments
 (0)