Skip to content

Commit 65d9d2c

Browse files
thomasmeydavem330
authored andcommitted
RxRPC: Use kmemdup rather than duplicating its implementation
The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci. Signed-off-by: Thomas Meyer <thomas@m3y3r.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent cb50870 commit 65d9d2c

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎net/rxrpc/ar-key.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -306,10 +306,9 @@ static int rxrpc_krb5_decode_tagged_data(struct krb5_tagged_data *td,
306306
td->data_len = len;
307307

308308
if (len > 0) {
309-
td->data = kmalloc(len, GFP_KERNEL);
309+
td->data = kmemdup(xdr, len, GFP_KERNEL);
310310
if (!td->data)
311311
return -ENOMEM;
312-
memcpy(td->data, xdr, len);
313312
len = (len + 3) & ~3;
314313
toklen -= len;
315314
xdr += len >> 2;
@@ -401,10 +400,9 @@ static int rxrpc_krb5_decode_ticket(u8 **_ticket, u16 *_tktlen,
401400
_debug("ticket len %u", len);
402401

403402
if (len > 0) {
404-
*_ticket = kmalloc(len, GFP_KERNEL);
403+
*_ticket = kmemdup(xdr, len, GFP_KERNEL);
405404
if (!*_ticket)
406405
return -ENOMEM;
407-
memcpy(*_ticket, xdr, len);
408406
len = (len + 3) & ~3;
409407
toklen -= len;
410408
xdr += len >> 2;

0 commit comments

Comments
 (0)