Skip to content

Commit

Permalink
platform/x86: hp-bioscfg: move mutex_lock() down in hp_add_other_attr…
Browse files Browse the repository at this point in the history
…ibutes()

attr_name_kobj's memory allocation is done with mutex_lock() held, this
is not needed.

Move allocation outside of mutex_lock() so unlock is not needed when
allocation fails.

Suggested-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Link: https://lore.kernel.org/r/20231113200742.3593548-2-harshit.m.mogalapalli@oracle.com
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
  • Loading branch information
Harshit Mogalapalli authored and Ilpo Järvinen committed Nov 15, 2023
1 parent c5dbf04 commit 5736aa9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions drivers/platform/x86/hp/hp-bioscfg/bioscfg.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,13 +592,11 @@ static int hp_add_other_attributes(int attr_type)
int ret;
char *attr_name;

mutex_lock(&bioscfg_drv.mutex);

attr_name_kobj = kzalloc(sizeof(*attr_name_kobj), GFP_KERNEL);
if (!attr_name_kobj) {
ret = -ENOMEM;
goto err_other_attr_init;
}
if (!attr_name_kobj)
return -ENOMEM;

mutex_lock(&bioscfg_drv.mutex);

/* Check if attribute type is supported */
switch (attr_type) {
Expand Down

0 comments on commit 5736aa9

Please sign in to comment.