Skip to content

Commit 6bc7ea3

Browse files
XueBing Chenvinodkoul
authored andcommitted
dmaengine: dmatest: use strscpy to replace strlcpy
The strlcpy should not be used because it doesn't limit the source length. Preferred is strscpy. Signed-off-by: XueBing Chen <chenxuebing@jari.cn> Link: https://lore.kernel.org/r/12e4cf06.a35.180fa748c29.Coremail.chenxuebing@jari.cn Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent a71da24 commit 6bc7ea3

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

drivers/dma/dmatest.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,8 +1101,8 @@ static void add_threaded_test(struct dmatest_info *info)
11011101

11021102
/* Copy test parameters */
11031103
params->buf_size = test_buf_size;
1104-
strlcpy(params->channel, strim(test_channel), sizeof(params->channel));
1105-
strlcpy(params->device, strim(test_device), sizeof(params->device));
1104+
strscpy(params->channel, strim(test_channel), sizeof(params->channel));
1105+
strscpy(params->device, strim(test_device), sizeof(params->device));
11061106
params->threads_per_chan = threads_per_chan;
11071107
params->max_channels = max_channels;
11081108
params->iterations = iterations;
@@ -1246,7 +1246,7 @@ static int dmatest_chan_set(const char *val, const struct kernel_param *kp)
12461246
dtc = list_last_entry(&info->channels,
12471247
struct dmatest_chan,
12481248
node);
1249-
strlcpy(chan_reset_val,
1249+
strscpy(chan_reset_val,
12501250
dma_chan_name(dtc->chan),
12511251
sizeof(chan_reset_val));
12521252
ret = -EBUSY;
@@ -1269,14 +1269,14 @@ static int dmatest_chan_set(const char *val, const struct kernel_param *kp)
12691269
if ((strcmp(dma_chan_name(dtc->chan), strim(test_channel)) != 0)
12701270
&& (strcmp("", strim(test_channel)) != 0)) {
12711271
ret = -EINVAL;
1272-
strlcpy(chan_reset_val, dma_chan_name(dtc->chan),
1272+
strscpy(chan_reset_val, dma_chan_name(dtc->chan),
12731273
sizeof(chan_reset_val));
12741274
goto add_chan_err;
12751275
}
12761276

12771277
} else {
12781278
/* Clear test_channel if no channels were added successfully */
1279-
strlcpy(chan_reset_val, "", sizeof(chan_reset_val));
1279+
strscpy(chan_reset_val, "", sizeof(chan_reset_val));
12801280
ret = -EBUSY;
12811281
goto add_chan_err;
12821282
}
@@ -1301,7 +1301,7 @@ static int dmatest_chan_get(char *val, const struct kernel_param *kp)
13011301
mutex_lock(&info->lock);
13021302
if (!is_threaded_test_run(info) && !is_threaded_test_pending(info)) {
13031303
stop_threaded_test(info);
1304-
strlcpy(test_channel, "", sizeof(test_channel));
1304+
strscpy(test_channel, "", sizeof(test_channel));
13051305
}
13061306
mutex_unlock(&info->lock);
13071307

0 commit comments

Comments
 (0)