From d5a8697f1cb320c3a25ea899d06d586e66b0671d Mon Sep 17 00:00:00 2001 From: Konstantin Makariev Date: Tue, 18 Sep 2018 11:18:45 -0500 Subject: [PATCH] utags: add one null byte in the end of payload This is propagation of the patch submitted under (CR) into DLKM utags driver Change-Id: Ia0321e9560f0afddd19f31326008da0714304afa Signed-off-by: Konstantin Makariev Reviewed-on: https://gerrit.mot.com/1243363 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Master Yoda Reviewed-by: Konstantin Makariev Submit-Approved: Jira Key --- drivers/misc/utag/utags.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/misc/utag/utags.c b/drivers/misc/utag/utags.c index e81d55bfa645..ab858171201c 100644 --- a/drivers/misc/utag/utags.c +++ b/drivers/misc/utag/utags.c @@ -770,7 +770,7 @@ static struct utag *thaw_tags(size_t block_size, void *buf) } if (cur->size != 0) { - cur->payload = kzalloc(cur->size, GFP_KERNEL); + cur->payload = kzalloc(cur->size + 1, GFP_KERNEL); if (!cur->payload) goto err_free; memcpy(cur->payload, frozen->payload, cur->size); @@ -1061,7 +1061,7 @@ static int check_utag_range(char *tag, struct utag *head, char *data, } /* make local copy of .range payload to tokenize */ - buf = ptr = kzalloc(range->size, GFP_KERNEL); + buf = ptr = kzalloc(range->size + 1, GFP_KERNEL); if (!buf) return -ENOMEM; @@ -1106,7 +1106,7 @@ static int replace_first_utag(struct utag *head, char *name, return -EIO; } - utag->payload = kzalloc(size, GFP_KERNEL); + utag->payload = kzalloc(size + 1, GFP_KERNEL); if (!utag->payload) { utag->payload = oldpayload; return -EIO;