Received: by 10.213.65.68 with SMTP id h4csp1496413imn; Mon, 26 Mar 2018 08:38:08 -0700 (PDT) X-Google-Smtp-Source: AG47ELu7A5li74kqyETreyArS0xJzX9UwtNgdUGBdpijOyoCBhh5JvyhzZ6UrN2PDmoDqlE1vqMM X-Received: by 2002:a17:902:d03:: with SMTP id 3-v6mr41453587plu.245.1522078688821; Mon, 26 Mar 2018 08:38:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522078688; cv=none; d=google.com; s=arc-20160816; b=E92xPYKqRaXQ7usYnJHGJdMScNCPrNVNo+sBalZyRM9CnqiPgcyFKFmTzpx1MfM3TI fDdKa9n1bRO7Bix1T/9NYUm1pddONm9i7dnIgvb5WRdxwNkyU6IH0oVQMxIx0akwAVVm JAz5VRmr9tdh7m9pfUETpU8A8La3Xfq2FwDMIPX0W78qNrAvNvu4MUsp+rNmsOk7+7AB MaCPur8h5i7CBJFHRPaWTH2duZKdv+UyOOBI6BKyygli053r1EMiz54wv3GFHJFhlrl6 FJ0ul8tt1bsq4BKrK8Wb3bqQte4uoDllF1qPvgCaiscqPvo+2epTmZjjalcc00lavxbA bbFQ== 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:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=dvHC7IEjaNzLmrdRYJV4sQeFFlV2SJx1gNWHOi/p6qM=; b=a64T4lIfrZtz3rnyc46kR7sGm6rkCiIydhj+WJGhthJmGgyJNfc4aTroiNqw45OL2i KA/B2q3k0g8RzZ9OkL0rUCyGJBlJQqOivNsPdb4BhkWAv8tslQy9DIu9dI1kixLulGpT o1ng8KNUmKl+vX0uDH2qeE1+KR/0xUmzfdojbzMvAW66p9ut6pD/Rvn/WusKExBvnncO QkP8KXuanykH7NNDq3IH5SBB35425mI7wgFJsjUGfCRssHeZgt9UumMuI6sTPqVT/mbk SRG3PtAukoCeWUzqXpldk2maEhYC9Q5aFYnxyasW0FLLltOXXkejkQzYYmmZfBF09OAs P7fQ== 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 v12-v6si15114498plz.579.2018.03.26.08.37.52; Mon, 26 Mar 2018 08:38:08 -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 S1752555AbeCZPgN (ORCPT + 99 others); Mon, 26 Mar 2018 11:36:13 -0400 Received: from esa1.microchip.iphmx.com ([68.232.147.91]:36019 "EHLO esa1.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189AbeCZPgL (ORCPT ); Mon, 26 Mar 2018 11:36:11 -0400 X-IronPort-AV: E=Sophos;i="5.48,365,1517900400"; d="scan'208";a="13280737" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa1.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Mar 2018 08:35:58 -0700 Received: from ajaysk-VirtualBox (10.10.76.4) by chn-sv-exch07.mchp-main.com (10.10.76.108) with Microsoft SMTP Server id 14.3.352.0; Mon, 26 Mar 2018 08:35:56 -0700 Date: Mon, 26 Mar 2018 21:05:48 +0530 From: Ajay Singh To: Colin King CC: Joe Perches , Aditya Shankar , Ganesh Krishna , Greg Kroah-Hartman , , , , Subject: Re: [PATCH] staging: wilc1000: check for kmalloc allocation failures Message-ID: <20180326210548.791f070a@ajaysk-VirtualBox> In-Reply-To: <1521662598.7999.33.camel@perches.com> References: <20180321191941.4126-1-colin.king@canonical.com> <1521662598.7999.33.camel@perches.com> Organization: Microchip Techonology X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for submitting the patch. On Wed, 21 Mar 2018 13:03:18 -0700 Joe Perches wrote: > On Wed, 2018-03-21 at 19:19 +0000, Colin King wrote: > > From: Colin Ian King > > > > There are three kmalloc allocations that are not null checked which > > potentially could lead to null pointer dereference issues. Fix this > > by adding null pointer return checks. > > looks like all of these should be kmemdup or kstrdup > > > > > @@ -951,6 +955,10 @@ static s32 handle_connect(struct wilc_vif *vif, > > if (conn_attr->ssid) { > > hif_drv->usr_conn_req.ssid = kmalloc(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); With this changes the Coverity reported warning is handled correctly. For further improvement to the patch, as Joe Perches suggested, its better to make use of kmemdup instead of kmalloc & memcpy. As kstrdup requires the source string to be NULL terminated('\0') and conn_attr->ssid might not contains the '\0' terminated string. So kmemdup with length of 'conn_attr->ssid_len' can be used instead. Please include the changes by using kmemdup() for all kmalloc/memcpy in this patch. Regards, Ajay