Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1478398ybh; Thu, 23 Jul 2020 09:50:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo4GGLms/Sq6DC/oNQ0zk0w2ZGNB9BwQIwRKNS19VZKTUliK/H8up++lpCizn+5rydNuek X-Received: by 2002:a17:906:9381:: with SMTP id l1mr5098914ejx.20.1595523042370; Thu, 23 Jul 2020 09:50:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595523042; cv=none; d=google.com; s=arc-20160816; b=T+MmHCmHySnRyHKWRHL9pqFMOlbvO1KxE6H/4z3fshGmdOIsBfgK9hQpodqp7/A3i0 JjwCZMK8paXHQJjI/P8OwxU132nZIHeJtxcj/BhXcm8ST9PEwgYZamBIKHXxbFOolU1D 0MItWYC/kkn3Y7kMMrnGRiXvaJHQj1Z/f80xtVZWp4AhQZpx2XRgTETg3g+oHH9YBrK5 vNPo3CZccay5hIE/eM2LPeURkM3vWdPr2uf9iVEsPC0iOd7Fv2TerQi2QKlFY+IFahCz XDjfA63wZ73bzFBLDitIzjiJqjVxnKwpYVxf7LQHpkEesxP5jG1lNGTHebuBGUUXY9BK 5T2Q== 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:autocrypt:from:references:cc:to:subject:dkim-signature; bh=mX9WbPR2A08lAhxlpv9nqKTZKz1fenNVDE+tR5xQ44Q=; b=ICftSXyc92PMg/H4fNnEtE0Sd9JHpPUDfpyC1WIDhMSg3BNnLXf8GcmK1HBm1g9X0y +DVoJXXIqRokeWecvJkKsOuXz1ySdGbEwOqBhqkkVPBGJ1ItJ6FXz8eu4v+dMf2MJtxK R+mHDy29DQQ1dNw1MVc+I9uKJoDJCa9p+ZV/Bg3nbzzUiiBTrhKHNMoYDuipUdLczabp LN5nVSGAqawhBho29nIkEv4o6hUcjKAEDfectUeJTUbdSGj6wz4XbLO+p5BDMyhwO+8d nU2S6+5PS7YZAnsDIcEN3mYQqgaZzB0MmntvyvJ+FGm4n5LeOzD5/RxOwZ/lL4TfRNsE SkRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Q+TYD5S7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bd1si2250935edb.290.2020.07.23.09.50.19; Thu, 23 Jul 2020 09:50:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@embeddedor.com header.s=default header.b=Q+TYD5S7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729909AbgGWQtd (ORCPT + 99 others); Thu, 23 Jul 2020 12:49:33 -0400 Received: from gateway32.websitewelcome.com ([192.185.144.98]:19993 "EHLO gateway32.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgGWQtb (ORCPT ); Thu, 23 Jul 2020 12:49:31 -0400 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway32.websitewelcome.com (Postfix) with ESMTP id 090BA28E714 for ; Thu, 23 Jul 2020 11:49:28 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id yePPjNyXrwgQAyePQjObcs; Thu, 23 Jul 2020 11:49:28 -0500 X-Authority-Reason: nr=8 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=embeddedor.com; s=default; h=Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Subject:Sender :Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=mX9WbPR2A08lAhxlpv9nqKTZKz1fenNVDE+tR5xQ44Q=; b=Q+TYD5S7vFBz3TXmZyJys1Ag2u 48HcHd05NsTizQ1KY8e5i23+ZGgg+3NcoaThhzQ+5Lh3XqshtM2AqgxKcRAG5N6xMooYoIKRQUT0W Ujcw1e+mxNNuw1XXqv0KSM5JEjHdSGoOUBW3emIV4izevVHPDYdvNaYP6jGngi+NNXYWpI58hQVqJ b8DkJBwmyq9SNz9m9D5n99EUDT2fo55vmYkZK39CXVJvV+IDdCvL+ztU2c1wgF+gU2GagPRO+64Bx hNNl+NHWA07Yt35hfzZhHWygWtsk0+TwE79YLPUic4etiAK1nFlzSeQO35W6b1FmnKUBqiSAmb8p/ drKd4pGg==; Received: from [201.162.245.27] (port=42558 helo=[192.168.43.132]) by gator4166.hostgator.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.93) (envelope-from ) id 1jyePP-0040ek-GZ; Thu, 23 Jul 2020 11:49:27 -0500 Subject: Re: [char-misc-next 3/6] mei: bus: use sizeof of variable instead of struct type To: Tomas Winkler , Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, "Gustavo A . R . Silva" , Arnd Bergmann References: <20200723145927.882743-1-tomas.winkler@intel.com> <20200723145927.882743-4-tomas.winkler@intel.com> From: "Gustavo A. R. Silva" Autocrypt: addr=gustavo@embeddedor.com; keydata= xsFNBFssHAwBEADIy3ZoPq3z5UpsUknd2v+IQud4TMJnJLTeXgTf4biSDSrXn73JQgsISBwG 2Pm4wnOyEgYUyJd5tRWcIbsURAgei918mck3tugT7AQiTUN3/5aAzqe/4ApDUC+uWN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anpcAEQEAAcLBZQQY AQgADwUCWywcDAIbDAUJCWYBgAAKCRBHBbTLRwbbMdsZEACUjmsJx2CAY+QSUMebQRFjKavw XB/xE7fTt2ahuhHT8qQ/lWuRQedg4baInw9nhoPE+VenOzhGeGlsJ0Ys52sdXvUjUocKgUQq 6ekOHbcw919nO5L9J2ejMf/VC/quN3r3xijgRtmuuwZjmmi8ct24TpGeoBK4WrZGh/1hAYw4 ieARvKvgjXRstcEqM5thUNkOOIheud/VpY+48QcccPKbngy//zNJWKbRbeVnimua0OpqRXhC rEVm/xomeOvl1WK1BVO7z8DjSdEBGzbV76sPDJb/fw+y+VWrkEiddD/9CSfgfBNOb1p1jVnT 2mFgGneIWbU0zdDGhleI9UoQTr0e0b/7TU+Jo6TqwosP9nbk5hXw6uR5k5PF8ieyHVq3qatJ 9K1jPkBr8YWtI5uNwJJjTKIA1jHlj8McROroxMdI6qZ/wZ1ImuylpJuJwCDCORYf5kW61fcr HEDlIvGc371OOvw6ejF8ksX5+L2zwh43l/pKkSVGFpxtMV6d6J3eqwTafL86YJWH93PN+ZUh 6i6Rd2U/i8jH5WvzR57UeWxE4P8bQc0hNGrUsHQH6bpHV2lbuhDdqo+cM9ehGZEO3+gCDFmK rjspZjkJbB5Gadzvts5fcWGOXEvuT8uQSvl+vEL0g6vczsyPBtqoBLa9SNrSVtSixD1uOgyt AP7RWS474w== Message-ID: Date: Thu, 23 Jul 2020 11:55:11 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200723145927.882743-4-tomas.winkler@intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 201.162.245.27 X-Source-L: No X-Exim-ID: 1jyePP-0040ek-GZ X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: ([192.168.43.132]) [201.162.245.27]:42558 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 22 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 7/23/20 09:59, Tomas Winkler wrote: > There is a possibility of bug when variable type has changed but > corresponding struct passed to the sizeof has not. > > Cc: Gustavo A. R. Silva > Signed-off-by: Tomas Winkler Reviewed-by: Gustavo A. R. Silva Thanks -- Gustavo > --- > drivers/misc/mei/bus-fixup.c | 23 +++++++++++------------ > drivers/misc/mei/bus.c | 2 +- > 2 files changed, 12 insertions(+), 13 deletions(-) > > diff --git a/drivers/misc/mei/bus-fixup.c b/drivers/misc/mei/bus-fixup.c > index 910f059b3384..07ba16d46690 100644 > --- a/drivers/misc/mei/bus-fixup.c > +++ b/drivers/misc/mei/bus-fixup.c > @@ -1,6 +1,6 @@ > // SPDX-License-Identifier: GPL-2.0 > /* > - * Copyright (c) 2013-2019, Intel Corporation. All rights reserved. > + * Copyright (c) 2013-2020, Intel Corporation. All rights reserved. > * Intel Management Engine Interface (Intel MEI) Linux driver > */ > > @@ -159,17 +159,17 @@ static int mei_osver(struct mei_cl_device *cldev) > static int mei_fwver(struct mei_cl_device *cldev) > { > char buf[MKHI_FWVER_BUF_LEN]; > - struct mkhi_msg *req; > + struct mkhi_msg req; > + struct mkhi_msg *rsp; > struct mkhi_fw_ver *fwver; > int bytes_recv, ret, i; > > memset(buf, 0, sizeof(buf)); > > - req = (struct mkhi_msg *)buf; > - req->hdr.group_id = MKHI_GEN_GROUP_ID; > - req->hdr.command = MKHI_GEN_GET_FW_VERSION_CMD; > + req.hdr.group_id = MKHI_GEN_GROUP_ID; > + req.hdr.command = MKHI_GEN_GET_FW_VERSION_CMD; > > - ret = __mei_cl_send(cldev->cl, buf, sizeof(struct mkhi_msg_hdr), > + ret = __mei_cl_send(cldev->cl, (u8 *)&req, sizeof(req), > MEI_CL_IO_TX_BLOCKING); > if (ret < 0) { > dev_err(&cldev->dev, "Could not send ReqFWVersion cmd\n"); > @@ -188,7 +188,8 @@ static int mei_fwver(struct mei_cl_device *cldev) > return -EIO; > } > > - fwver = (struct mkhi_fw_ver *)req->data; > + rsp = (struct mkhi_msg *)buf; > + fwver = (struct mkhi_fw_ver *)rsp->data; > memset(cldev->bus->fw_ver, 0, sizeof(cldev->bus->fw_ver)); > for (i = 0; i < MEI_MAX_FW_VER_BLOCKS; i++) { > if ((size_t)bytes_recv < MKHI_FWVER_LEN(i + 1)) > @@ -329,16 +330,14 @@ static int mei_nfc_if_version(struct mei_cl *cl, > > WARN_ON(mutex_is_locked(&bus->device_lock)); > > - ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(struct mei_nfc_cmd), > - MEI_CL_IO_TX_BLOCKING); > + ret = __mei_cl_send(cl, (u8 *)&cmd, sizeof(cmd), MEI_CL_IO_TX_BLOCKING); > if (ret < 0) { > dev_err(bus->dev, "Could not send IF version cmd\n"); > return ret; > } > > /* to be sure on the stack we alloc memory */ > - if_version_length = sizeof(struct mei_nfc_reply) + > - sizeof(struct mei_nfc_if_version); > + if_version_length = sizeof(*reply) + sizeof(*ver); > > reply = kzalloc(if_version_length, GFP_KERNEL); > if (!reply) > @@ -352,7 +351,7 @@ static int mei_nfc_if_version(struct mei_cl *cl, > goto err; > } > > - memcpy(ver, reply->data, sizeof(struct mei_nfc_if_version)); > + memcpy(ver, reply->data, sizeof(*ver)); > > dev_info(bus->dev, "NFC MEI VERSION: IVN 0x%x Vendor ID 0x%x Type 0x%x\n", > ver->fw_ivn, ver->vendor_id, ver->radio_type); > diff --git a/drivers/misc/mei/bus.c b/drivers/misc/mei/bus.c > index f476dbc7252b..a6dfc3ce1db2 100644 > --- a/drivers/misc/mei/bus.c > +++ b/drivers/misc/mei/bus.c > @@ -931,7 +931,7 @@ static struct mei_cl_device *mei_cl_bus_dev_alloc(struct mei_device *bus, > struct mei_cl_device *cldev; > struct mei_cl *cl; > > - cldev = kzalloc(sizeof(struct mei_cl_device), GFP_KERNEL); > + cldev = kzalloc(sizeof(*cldev), GFP_KERNEL); > if (!cldev) > return NULL; > >