Skip to content

Commit 5736aa9

Browse files
harshimogalapalliij-intel
authored andcommitted
platform/x86: hp-bioscfg: move mutex_lock() down in hp_add_other_attributes()
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 <[email protected]> Signed-off-by: Harshit Mogalapalli <[email protected]> Reviewed-by: Ilpo Järvinen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ilpo Järvinen <[email protected]>
1 parent c5dbf04 commit 5736aa9

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

drivers/platform/x86/hp/hp-bioscfg/bioscfg.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -592,13 +592,11 @@ static int hp_add_other_attributes(int attr_type)
592592
int ret;
593593
char *attr_name;
594594

595-
mutex_lock(&bioscfg_drv.mutex);
596-
597595
attr_name_kobj = kzalloc(sizeof(*attr_name_kobj), GFP_KERNEL);
598-
if (!attr_name_kobj) {
599-
ret = -ENOMEM;
600-
goto err_other_attr_init;
601-
}
596+
if (!attr_name_kobj)
597+
return -ENOMEM;
598+
599+
mutex_lock(&bioscfg_drv.mutex);
602600

603601
/* Check if attribute type is supported */
604602
switch (attr_type) {

0 commit comments

Comments
 (0)