Received: by 10.192.165.148 with SMTP id m20csp425000imm; Wed, 2 May 2018 02:43:34 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpYsipbTceNjfoBX7zga/lfBHganhhVdkgMxkFBZ6eo0Cn40Or9qqYHncHiy0oLfRu4QEFR X-Received: by 2002:a17:902:7109:: with SMTP id a9-v6mr19623148pll.271.1525254214634; Wed, 02 May 2018 02:43:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525254214; cv=none; d=google.com; s=arc-20160816; b=RCL5oFaqySRKSojHu9Jsd45aANOkhJ6K9C1V3hcJmNLhCjXS6cbeIM8jtKR3h8gEYS txjzi+Dadf2BrJdhaE6R82RNXeWik4lwcKXk3Xj8SGAHh6N2SLbYEO4LmZb/OoiBmfWw QI8N5zW1THiw1GEIZDP1C4uA5ZY2H03k2tjoPHg7qLjbdOLto/TAhFwKRr4qHWvocda4 xMmYNipNa2AK75Vk0Sy//SOEL4cmW/qw0HRGu5W4sqv7RfzFoKCZufI05gUj1v+VCFWK R5tyl6zoGaOheT7gDhmgAmg6ZWDh4cHbT5wfLpdSEL2J2i5lcRG4x7xVkpKzfPxQnD8W YOVg== 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=KT+Iciglsdex/ZayIbZ36mfYsUDX3bi+4gLl8AygUGI=; b=jQrbRULiVTQ9Dp3H9VIQxpBCwEPPhQ9cG9gotefKHnnBIy6WQeO0xARmK6OEHYxltY PRLV3Swj058GsV4bUCzo5xWq9veOR3XdNMm/MSvBSJJ7UAd1SJoCCLt05N3Gq9JURchv dDQO7bbkrchvE5loQ+ks+jLUMgtGAQTw6e8eCPFb1zC4tZHidI/aQFjKiOLLMoIrd5sK 1XnUrPg4OdCkxal8QmczXh6bYuK39JYxmhr5CBotKYcvedilnSLtOb+TaKQbgSQ550bt /Vz70dPLBkUPrETJZh3z5LMbkv+gf9tq1IAj9yPJXLKMZmP94saNCVVkLWPXM3u5T9uZ eo9A== 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 s204-v6si2005269pgs.164.2018.05.02.02.43.20; Wed, 02 May 2018 02:43: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; 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 S1751502AbeEBJml (ORCPT + 99 others); Wed, 2 May 2018 05:42:41 -0400 Received: from esa4.microchip.iphmx.com ([68.232.154.123]:29470 "EHLO esa4.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750907AbeEBJmk (ORCPT ); Wed, 2 May 2018 05:42:40 -0400 X-IronPort-AV: E=Sophos;i="5.49,354,1520924400"; d="scan'208";a="13460973" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa4.microchip.iphmx.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 02 May 2018 02:42:39 -0700 Received: from ajaysk-VirtualBox (10.10.76.4) by chn-sv-exch02.mchp-main.com (10.10.76.38) with Microsoft SMTP Server id 14.3.352.0; Wed, 2 May 2018 02:42:38 -0700 Date: Wed, 2 May 2018 15:12:29 +0530 From: Ajay Singh To: Dan Carpenter CC: , "Gustavo A. R. Silva" , , , , "Ganesh Krishna" , Greg Kroah-Hartman Subject: Re: [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access Message-ID: <20180502151229.4be29ec8@ajaysk-VirtualBox> In-Reply-To: <20180502083935.uw4mxvcgnpayv3h3@mwanda> References: <20180430125040.GA19050@embeddedor.com> <20180430195916.596a93eb@ajaysk-VirtualBox> <20180430152321.7pq4ol2ed7tzsrl4@mwanda> <20180502111735.5a2c6faa@ajaysk-VirtualBox> <20180502083935.uw4mxvcgnpayv3h3@mwanda> Organization: Microchip Technology 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 On Wed, 2 May 2018 11:39:36 +0300 Dan Carpenter wrote: > We're mainly discussing readability, right? > > To me when people use "int" that tells me as a reader that we don't > need to think about the type. It's going to be a small number. > > Say you have data which the user can control, then it's super > important to focus on the data types. We don't focus on it > enough. There is some kind of idea that good developers should > just be super focused on everything all the time, but I don't think > humans can do it. So to me it's useful when the author tells me, > "This an int type. It's fine. This is not critical." > > If you make request->n_ssids a u8 or u16, that isn't going to save > any memory because the struct is padded. You'd also need to audit > a bunch of code to make sure that we don't overflow the u16. If > you wanted to overflow the int, you'd need to allocate several gigs > of memory but kmalloc() is capped at KMALLOC_MAX_SIZE (4MB) so > that's not possible. How many of these structs do we allocate? Is > it really worth optimizing the heck out of it? > > There are times where want to be very deliberate with our types > because we're dealing the large numbers, or user data or fast > paths. But there are other times where int is fine... > As in this case, its fine to be of 'int' type. So we can retain the current data type('int') for 'i' and 'slot_id'. Thank you for sharing your insights,it was very helpful. Regards, Ajay