Skip to content

Commit

Permalink
soc: ti: fix max dup length for kstrndup
Browse files Browse the repository at this point in the history
If source string longer than max, kstrndup will alloc max+1 space.
So, we should make sure the result will not over limit.

Signed-off-by: Ma Shimiao <[email protected]>
Signed-off-by: Santosh Shilimkar <[email protected]>
  • Loading branch information
Ma Shimiao authored and SantoshShilimkar committed Dec 16, 2017
1 parent bd0fa74 commit aefc581
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/soc/ti/knav_qmss_queue.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ static struct knav_queue *__knav_queue_open(struct knav_queue_inst *inst,
if (!knav_queue_is_busy(inst)) {
struct knav_range_info *range = inst->range;

inst->name = kstrndup(name, KNAV_NAME_SIZE, GFP_KERNEL);
inst->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL);
if (range->ops && range->ops->open_queue)
ret = range->ops->open_queue(range, inst, flags);

Expand Down Expand Up @@ -779,7 +779,7 @@ void *knav_pool_create(const char *name,
goto err;
}

pool->name = kstrndup(name, KNAV_NAME_SIZE, GFP_KERNEL);
pool->name = kstrndup(name, KNAV_NAME_SIZE - 1, GFP_KERNEL);
pool->kdev = kdev;
pool->dev = kdev->dev;

Expand Down

0 comments on commit aefc581

Please sign in to comment.