Skip to content

Commit fe399aa

Browse files
Vitaliy Shevtsovgregkh
authored andcommitted
scsi: elx: efct: Fix memory leak in efct_hw_parse_filter()
[ Upstream commit 2a8a5a5dd06eef580f9818567773fd75057cb875 ] strsep() modifies the address of the pointer passed to it so that it no longer points to the original address. This means kfree() gets the wrong pointer. Fix this by passing unmodified pointer returned from kstrdup() to kfree(). Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 4df84e8 ("scsi: elx: efct: Driver initialization routines") Signed-off-by: Vitaliy Shevtsov <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Daniel Wagner <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent 01f91d4 commit fe399aa

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

drivers/scsi/elx/efct/efct_hw.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ int
11201120
efct_hw_parse_filter(struct efct_hw *hw, void *value)
11211121
{
11221122
int rc = 0;
1123-
char *p = NULL;
1123+
char *p = NULL, *pp = NULL;
11241124
char *token;
11251125
u32 idx = 0;
11261126

@@ -1132,6 +1132,7 @@ efct_hw_parse_filter(struct efct_hw *hw, void *value)
11321132
efc_log_err(hw->os, "p is NULL\n");
11331133
return -ENOMEM;
11341134
}
1135+
pp = p;
11351136

11361137
idx = 0;
11371138
while ((token = strsep(&p, ",")) && *token) {
@@ -1144,7 +1145,7 @@ efct_hw_parse_filter(struct efct_hw *hw, void *value)
11441145
if (idx == ARRAY_SIZE(hw->config.filter_def))
11451146
break;
11461147
}
1147-
kfree(p);
1148+
kfree(pp);
11481149

11491150
return rc;
11501151
}

0 commit comments

Comments
 (0)