Received: by 10.213.65.68 with SMTP id h4csp328751imn; Tue, 13 Mar 2018 05:51:34 -0700 (PDT) X-Google-Smtp-Source: AG47ELu+HbK/m2monc4Rfi8rvBSSSE9sAbE/JB9TcQqN9aIKbqDEtPs+2A3HqCe3iMejI+NLktbV X-Received: by 2002:a17:902:4c88:: with SMTP id b8-v6mr511756ple.0.1520945494245; Tue, 13 Mar 2018 05:51:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520945494; cv=none; d=google.com; s=arc-20160816; b=0msibp2kUEfl+UhdKs3sr2UeJvq5+Q3Ta6h0V3D+GhSRX36Ndxfgky+Wev0DKoXPKh SQrhXYm444N+PZNErG/BhUlIKDYlHm5h5Rcm9rXTk8YFR3J3lrMIkoJ7Mx3RzUt3PDFP TUIOq/TObTCa8xg51j76OH+hsGRQE97K64HSLLSqMqEEXQ+QNwX8CnhbJ5b/g6nxvX2B X+LLSj3JhPsUSeLwIZeZbb1W3MQIYbvddfEf+mwH2Tdu21W9Wa4dEtpp/DLFn9YQDaqI Hor9z88lM/DQPXGNmYFtbXQqkKz+9Uc2Hy7yMuThBK22IHGcyDL4u49FdXHXBXYLV1BG /ykg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=YTCjNt1WHt1SF0BuPkr3vj/nKJ+JsYADQPQwogGW7Ss=; b=jsxKO5HeYiCwzne6/NEu7Ri5PytShCkzpYCbWvLIaCKdOHQ/7fMynQpMa3FTHn1UpZ HsgE1lO7zeiHyVkRWRD3vGsr10UCXXtx94J5pjzj+HSKDTAvKKHiPKtcHixxRRR8tAh9 qaPq2fVoK1W6uiE8FyYpZf9tFFP8ByhO1auq/lJn0wz88oc9Wwpre+ULyu8m548Rt31U ToCDNOUl4SVeIqwoN9pWNATwsSPV47UFsmZpxzUnf2kQsB3DujxREOK0mivLBqDq74Ir KXRtKAcacDhyXUoiSso+fW39BAx5F83PO/SKlUb3QImh68QvMv6arRJBE92yWEbDxiul 9ykg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kYj6iNdz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89-v6si88115plf.491.2018.03.13.05.51.20; Tue, 13 Mar 2018 05:51:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=kYj6iNdz; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752170AbeCMMty (ORCPT + 99 others); Tue, 13 Mar 2018 08:49:54 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:41131 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750860AbeCMMtw (ORCPT ); Tue, 13 Mar 2018 08:49:52 -0400 Received: by mail-pl0-f67.google.com with SMTP id d9-v6so11214385plo.8; Tue, 13 Mar 2018 05:49:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=YTCjNt1WHt1SF0BuPkr3vj/nKJ+JsYADQPQwogGW7Ss=; b=kYj6iNdzhjSUG/Tk7T6U7PSyo5dDENPTpjo3alKwakGTFI2hzKwj4g5V4sSdzeNfEr pVZCm3SS860NZ7nVqZCRGMVU9SeZOpNRl1Y/F2RUSAFNvgt5jRnD/gsjWfFvpGiwgPWE T5MN7E677Iw90ibES6niG4TZI3Ya6P8ft9QRcWCF2XNMsqmhCzuKMXpltEqkCaGKkOC2 i+3vN6KkUAyGMDGbWKHRVyCr7K07q8JLwe2Zk5jLGu/QnWOmiMEx/IeTNSO3OFCKm9HV eCdwdwOKh9vA/pEcMVPxN9Y/Z4WY0GYomXcL36mBYcfZRIRIZyb31u3gOtYN4XFVJq6A Gkzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=YTCjNt1WHt1SF0BuPkr3vj/nKJ+JsYADQPQwogGW7Ss=; b=Y22FyANiH1Z4bS4B/Q+qGNj1gx903uR4qtbVHjPRztCKe7XiSs0NzFE3aGa8HgEXci WnjJ3hd/XSX/n3pCSl48oPFTgfD50SaEHmGgwmb94S12TX1QJ/ixJwqXmcahiQwWyfIq ewp0MEtugQqP4v36xygfBYzqbOqzC32zYrLUPx0BH4NmIAP/jaUF3qe8SWN49H5uZ/fu bQ6dUtx6CUlJYwutLHRMcDnORm3VpkoczUk09xfPaCcHKCRq+Tak0K8qEljjOk/Vpfly xlrcq8mMFptkv4cnoPM3JEmWT71KqevTUmaA4n+sQNY/2EZntyNZLY7WCOVFzdci7+qA Tizg== X-Gm-Message-State: AElRT7H+sbEpyywhzv2l2NDV4lUpHU9dXyuDAtxtqSph3iN1MRZSZH41 Hz/ymMoHAd6eZhTDKnnpVjA= X-Received: by 2002:a17:902:74c5:: with SMTP id f5-v6mr462494plt.91.1520945391545; Tue, 13 Mar 2018 05:49:51 -0700 (PDT) Received: from localhost.localdomain ([2405:204:714b:73d3:f099:e200:ca11:baf8]) by smtp.gmail.com with ESMTPSA id m3sm270006pgs.90.2018.03.13.05.49.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 13 Mar 2018 05:49:50 -0700 (PDT) From: hariprasath.elango@gmail.com To: aditya.shankar@microchip.com, ganesh.krishna@microchip.com Cc: hariprasath.elango@gmail.com, Greg Kroah-Hartman , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] staging: wilc1000: use kmemdup to replace kmalloc/memcpy Date: Tue, 13 Mar 2018 18:19:32 +0530 Message-Id: <20180313124932.15038-1-hariprasath.elango@gmail.com> X-Mailer: git-send-email 2.10.0.GIT Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: HariPrasath Elango kmalloc followed by memcpy can be replaced by kmemdup.Also added the related error handling part Signed-off-by: HariPrasath Elango --- drivers/staging/wilc1000/host_interface.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index 0fac8e1..4ae2da6 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -992,9 +992,13 @@ static s32 handle_connect(struct wilc_vif *vif, if (memcmp("DIRECT-", pstrHostIFconnectAttr->ssid, 7)) { info_element_size = hif_drv->usr_conn_req.ies_len; - info_element = kmalloc(info_element_size, GFP_KERNEL); - memcpy(info_element, hif_drv->usr_conn_req.ies, - info_element_size); + info_element = kmemdup(hif_drv->usr_conn_req.ies, + info_element_size, + GFP_KERNEL); + if (!info_element) { + result = -ENOMEM; + goto ERRORHANDLER; + } } wid_list[wid_cnt].id = (u16)WID_11I_MODE; -- 2.10.0.GIT