Received: by 10.213.65.68 with SMTP id h4csp1611601imn; Mon, 26 Mar 2018 10:52:03 -0700 (PDT) X-Google-Smtp-Source: AG47ELuVwAeHokg9TWl9hv48VXFwIguFfoi9etY1ISzSuiGNZ5U1JzYW0CQMTGEd9QAYyrSdvTLJ X-Received: by 10.98.50.130 with SMTP id y124mr33890352pfy.147.1522086723272; Mon, 26 Mar 2018 10:52:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522086723; cv=none; d=google.com; s=arc-20160816; b=CRCLChBmdbwR6ZEbCqPhlz5fimCFcG2CAMUtzv3Ow/LtEP3XlPVMDNKxgEXA5rI+ZX ZnqMn176eKExOUBcdmEQJI9jziB73Ad0T0cXBqFdxrOvdHDOgtF1VyyY7H0egm5NYD4p L/5K8z51TJK6PfSOvIv6gHH1tGzqZU2wh6Sr3gJVYQL/KsZ1eaY60ALf014rQK49LG0F f/Xg9LjtoNt9G7tbbTntrkCxa4KzpfKQW6qmr4e9H6KKGqQmOuMgq08xBP8JaRhkQ/yB YtdDTDJ0LHaopamMgCQNbLKSDOhwwm7NBwNGh0LsGC9aNZfjzorpQ9bhvLOEf0BM+Tkc C6ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:newsgroups:cc:to:subject :arc-authentication-results; bh=7zd36t6WIgtd/DBvkxp+/4Bhho7LUFLEjKwpOJPO3f8=; b=XdePrvTBGhPUrrU3t7vCldUaWEzSgn03LYs084WTWq1adA/VgRxO7+zF8mpmRto7Yo QZhrE/GYIdwjfn4Z8sH7eLRwm0plWiVgneX/gy8WLrKhJ8l7XpHHcZFHlXKrt0yg0YTY ASK0sZT86OvgAnPP0EQ0JB/C/eRW/O1ldG8x+AHxTSGdKqoyF7V3sVLsdTG1M7psakrt iPiISbcZ32hi1R1yWYLLMqWU5w10RXoIYVuzNE5Q9ivBs92iy5cx8iqviWnQfzA9jB0+ VpX+yZuW7FlCSVmHT88u6pqiq6V4n8GyZvVGz5KN9Tm5vqWxVzbGFB+ThutB1QatuF8s LsZA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b2-v6si11232868plz.588.2018.03.26.10.51.48; Mon, 26 Mar 2018 10:52:03 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752675AbeCZRuw (ORCPT + 99 others); Mon, 26 Mar 2018 13:50:52 -0400 Received: from smtp06.smtpout.orange.fr ([80.12.242.128]:19505 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752275AbeCZRuu (ORCPT ); Mon, 26 Mar 2018 13:50:50 -0400 Received: from [192.168.0.14] ([77.198.79.136]) by mwinf5d82 with ME id Shqm1x0052wTeBR03hqmFr; Mon, 26 Mar 2018 19:50:48 +0200 X-ME-Helo: [192.168.0.14] X-ME-Auth: Y2hyaXN0b3BoZS5qYWlsbGV0QHdhbmFkb28uZnI= X-ME-Date: Mon, 26 Mar 2018 19:50:48 +0200 X-ME-IP: 77.198.79.136 Subject: Re: [PATCH] staging: wilc1000: replace kmalloc + memcpy with kmemdup To: Colin King , Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Newsgroups: gmane.linux.drivers.driver-project.devel,gmane.linux.kernel.wireless.general,gmane.linux.kernel.janitors,gmane.linux.kernel References: <20180326171629.28700-1-colin.king@canonical.com> From: Christophe Jaillet Message-ID: Date: Mon, 26 Mar 2018 19:50:44 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180326171629.28700-1-colin.king@canonical.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit X-Antivirus: Avast (VPS 180326-0, 26/03/2018), Outbound message X-Antivirus-Status: Clean Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/03/2018 à 19:16, Colin King a écrit : > From: Colin Ian King > > Replace several allocation and memcpys with kmemdup and add in some > missing memory allocation failure checks. Also fix an incorrect > -EFAULT return with -ENOMEM. > > Signed-off-by: Colin Ian King > --- > drivers/staging/wilc1000/host_interface.c | 75 +++++++++++++++++++------------ > 1 file changed, 46 insertions(+), 29 deletions(-) > > diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c > index 9b9b86654958..8fd367f87fa5 100644 > --- a/drivers/staging/wilc1000/host_interface.c > +++ b/drivers/staging/wilc1000/host_interface.c [...] > > hif_drv->usr_conn_req.ssid_len = conn_attr->ssid_len; > if (conn_attr->ssid) { > - hif_drv->usr_conn_req.ssid = kmalloc(conn_attr->ssid_len + 1, > + hif_drv->usr_conn_req.ssid = kmemdup(conn_attr->ssid, > + conn_attr->ssid_len + 1, > GFP_KERNEL); > if (!hif_drv->usr_conn_req.ssid) { > result = -ENOMEM; > goto error; > } > - memcpy(hif_drv->usr_conn_req.ssid, > - conn_attr->ssid, > - conn_attr->ssid_len); > hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0'; I don't know if it is an issue, but now the memcpy is 1 more byte (conn_attr->ssid_len vs conn_attr->ssid_len + 1) kmemdup_nul(conn_attr->ssid, conn_attr->ssid_len, GFP_KERNEL) and remove hif_drv->usr_conn_req.ssid[conn_attr->ssid_len] = '\0' ? CJ [...]