From patchwork Wed Mar 14 12:45:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: hariprasath.elango@gmail.com X-Patchwork-Id: 10282071 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 83016601E9 for ; Wed, 14 Mar 2018 12:46:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 758BC288BC for ; Wed, 14 Mar 2018 12:46:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6A631288DB; Wed, 14 Mar 2018 12:46:15 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FF8D288BC for ; Wed, 14 Mar 2018 12:46:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751488AbeCNMp7 (ORCPT ); Wed, 14 Mar 2018 08:45:59 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:35523 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752052AbeCNMpz (ORCPT ); Wed, 14 Mar 2018 08:45:55 -0400 Received: by mail-pl0-f67.google.com with SMTP id w22-v6so1631674pll.2; Wed, 14 Mar 2018 05:45:55 -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:in-reply-to:references :in-reply-to:references; bh=YTCjNt1WHt1SF0BuPkr3vj/nKJ+JsYADQPQwogGW7Ss=; b=SJ1ODQNjz3s0MskJSBeFQqwIA4nN6K1FcxuMV4kDpSjMqQnO7KjvzTJbLJWdd8N5w1 n+yfDAyLATVD89e0mfw9UlyRt+tMAhSvGMTRiDSs6qShEikWt0R5s5H7CJmjH586pCam 494IrgiM0aJo00d4lJKd6iQkHwBOZJFJXBkS7jDTHMveEI60rBXdlgXpHX0lE6a5qYcG 66L33VVP/45Wd7hK3fRsbCdSSu3JRDR/DTQxjJOZzJxsCw+ZrTXO36XV6dfWRRIcerIi /O3tCt/6J0ZqQZdbBnGPO0vLufEf/PDnzWNZRQJHAe/1CNbz88mq7fUbXlJogevma8/i SVRA== 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:in-reply-to :references:in-reply-to:references; bh=YTCjNt1WHt1SF0BuPkr3vj/nKJ+JsYADQPQwogGW7Ss=; b=g/syD/fqJtclukdxS9FV9jYwrx/EdYI/Vt84MAKHflbAuk0tQ3cfRmnFiNtarVM196 QkPCGQz4Cvv+3twMqYgJslBHzGlQX4B4rGFUEQqEfKqbmHs+uMeCu4ouyhOJH08n8SBg DSW138olK9wOgb6WKTZfiH7hrhFPT94WHrxG+B3IcQZbTI3MoWBkfwuuuDkJ3bLxHlFM fnzX9nYkrVEa3EV7s++EYmoUaz1AYnuRDm9WtBd0Nl0yFDvc+o+vE6J7ZffmvKm662ox Wf+/TGE8SaFtNM+3fxDJUYUAmdtRqMXO6cpp3snJeBbnzT2FVwimHHv+3eQLIntD8/kw dWcA== X-Gm-Message-State: AElRT7EVea5isgPWwN5CcquKzLd+0BKy8LAKFu5bPw6WGJ1vq7cgbCpC Qdc/gEtQqxgZqgAo4i1pn27831Fx X-Google-Smtp-Source: AG47ELsNceW7/sFJjo290oppguWt5buASVOEa35NDKiqqM+1T1gYzl7/dbLFEKns+umRqgK4QbFKEg== X-Received: by 2002:a17:902:7d93:: with SMTP id a19-v6mr4053053plm.160.1521031555272; Wed, 14 Mar 2018 05:45:55 -0700 (PDT) Received: from localhost.localdomain ([2405:204:7142:9212:3d49:8166:4647:f07f]) by smtp.gmail.com with ESMTPSA id y14sm3999982pff.81.2018.03.14.05.45.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Mar 2018 05:45:54 -0700 (PDT) From: hariprasath.elango@gmail.com To: aditya.shankar@microchip.com, gregkh@linuxfoundation.org, ganesh.krishna@microchip.com Cc: hariprasath.elango@gmail.com, linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] staging: wilc1000: use kmemdup to replace kmalloc/memcpy Date: Wed, 14 Mar 2018 18:15:05 +0530 Message-Id: X-Mailer: git-send-email 2.10.0.GIT In-Reply-To: References: In-Reply-To: References: Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;