Skip to content

Commit

Permalink
target/configfs: use kmalloc() instead of kzalloc() for default groups
Browse files Browse the repository at this point in the history
All elements are assigned even the NULL member at the end so there is no
reason to allocate zeroed memory.

(nab: Fix up minor apply breakage in for-next)

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Sebastian Andrzej Siewior authored and Nicholas Bellinger committed Nov 28, 2012
1 parent a5675c8 commit 13f6a91
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions drivers/target/iscsi/iscsi_target_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ static struct se_node_acl *lio_target_make_nodeacl(
acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
stats_cg = &se_nacl->acl_fabric_stat_group;

stats_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!stats_cg->default_groups) {
pr_err("Unable to allocate memory for"
Expand Down Expand Up @@ -1268,7 +1268,7 @@ static struct se_wwn *lio_target_call_coreaddtiqn(
*/
stats_cg = &tiqn->tiqn_wwn.fabric_stat_group;

stats_cg->default_groups = kzalloc(sizeof(struct config_group *) * 6,
stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
GFP_KERNEL);
if (!stats_cg->default_groups) {
pr_err("Unable to allocate memory for"
Expand Down
14 changes: 7 additions & 7 deletions drivers/target/target_core_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2496,7 +2496,7 @@ static struct config_group *target_core_make_subdev(

dev_cg = &dev->dev_group;

dev_cg->default_groups = kzalloc(sizeof(struct config_group *) * 6,
dev_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
GFP_KERNEL);
if (!dev_cg->default_groups)
goto out_free_device;
Expand Down Expand Up @@ -2528,7 +2528,7 @@ static struct config_group *target_core_make_subdev(
dev->t10_alua.default_tg_pt_gp = tg_pt_gp;

tg_pt_gp_cg = &dev->t10_alua.alua_tg_pt_gps_group;
tg_pt_gp_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
tg_pt_gp_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!tg_pt_gp_cg->default_groups) {
pr_err("Unable to allocate tg_pt_gp_cg->"
Expand All @@ -2544,7 +2544,7 @@ static struct config_group *target_core_make_subdev(
* Add core/$HBA/$DEV/statistics/ default groups
*/
dev_stat_grp = &dev->dev_stat_grps.stat_group;
dev_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 4,
dev_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 4,
GFP_KERNEL);
if (!dev_stat_grp->default_groups) {
pr_err("Unable to allocate dev_stat_grp->default_groups\n");
Expand Down Expand Up @@ -2829,7 +2829,7 @@ static int __init target_core_init_configfs(void)
* and ALUA Logical Unit Group and Target Port Group infrastructure.
*/
target_cg = &subsys->su_group;
target_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
target_cg->default_groups = kmalloc(sizeof(struct config_group) * 2,
GFP_KERNEL);
if (!target_cg->default_groups) {
pr_err("Unable to allocate target_cg->default_groups\n");
Expand All @@ -2845,7 +2845,7 @@ static int __init target_core_init_configfs(void)
* Create ALUA infrastructure under /sys/kernel/config/target/core/alua/
*/
hba_cg = &target_core_hbagroup;
hba_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
hba_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!hba_cg->default_groups) {
pr_err("Unable to allocate hba_cg->default_groups\n");
Expand All @@ -2861,7 +2861,7 @@ static int __init target_core_init_configfs(void)
* groups under /sys/kernel/config/target/core/alua/
*/
alua_cg = &alua_group;
alua_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
alua_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!alua_cg->default_groups) {
pr_err("Unable to allocate alua_cg->default_groups\n");
Expand All @@ -2883,7 +2883,7 @@ static int __init target_core_init_configfs(void)
}

lu_gp_cg = &alua_lu_gps_group;
lu_gp_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
lu_gp_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!lu_gp_cg->default_groups) {
pr_err("Unable to allocate lu_gp_cg->default_groups\n");
Expand Down
6 changes: 3 additions & 3 deletions drivers/target/target_core_fabric_configfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ static struct config_group *target_fabric_make_mappedlun(
}

lacl_cg = &lacl->se_lun_group;
lacl_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
lacl_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!lacl_cg->default_groups) {
pr_err("Unable to allocate lacl_cg->default_groups\n");
Expand All @@ -373,7 +373,7 @@ static struct config_group *target_fabric_make_mappedlun(
lacl_cg->default_groups[1] = NULL;

ml_stat_grp = &lacl->ml_stat_grps.stat_group;
ml_stat_grp->default_groups = kzalloc(sizeof(struct config_group *) * 3,
ml_stat_grp->default_groups = kmalloc(sizeof(struct config_group *) * 3,
GFP_KERNEL);
if (!ml_stat_grp->default_groups) {
pr_err("Unable to allocate ml_stat_grp->default_groups\n");
Expand Down Expand Up @@ -858,7 +858,7 @@ static struct config_group *target_fabric_make_lun(
return ERR_PTR(-EINVAL);

lun_cg = &lun->lun_group;
lun_cg->default_groups = kzalloc(sizeof(struct config_group *) * 2,
lun_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
GFP_KERNEL);
if (!lun_cg->default_groups) {
pr_err("Unable to allocate lun_cg->default_groups\n");
Expand Down

0 comments on commit 13f6a91

Please sign in to comment.