Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3616732pxv; Mon, 19 Jul 2021 04:49:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxknhCtxx12lxJRcmf5ZN1iK4fUJVQNy3N2M6RfzS002I+JeWDtJTqNSRNFmBOzz2mAaio4 X-Received: by 2002:a05:6402:37a:: with SMTP id s26mr34544924edw.114.1626695396166; Mon, 19 Jul 2021 04:49:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626695396; cv=none; d=google.com; s=arc-20160816; b=Blk8YaNqDR6H8GxpEG+ZGdgBDg0QIGjil3GCPegkTFgrSFLZ0/Vsg6B0+xI/Z02zvB GP+VXfxNmXQrNoW3fgDoAVIHg6p8WT5gJkDOBXcnl0EdkdsRFNmU30ZPIpCqaWAY2Bu9 GIFamwNvNSR9RYfR5Fw32+pq6J1ULzRy1cFck49bD5g/trm5n1Z4FLWa2rXLBpvHYMZx DaaWk/pd7dtnPQtlUu/Vco3+CifLzN/AA3UM37QlMyRLicytC7lz0mR9tpJWNpysS3Ku snWwwE7CMPcES2/KELZZid4ft2sAWpAPAqEPn6Fho0LRx8/6LcCWgvJIx6cl9dV8hrmG 3RIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=trgV24lrgMFjAemVuZKWOXTFbx+tSNJWHibE9p2neUQ=; b=zKHI7Igq3oZST3k7vjIDAhdDxLEiTsBszQRKZLjeQJk+6Kf1h08LKYwKJ9Usq9G754 WDVsXWdDcJ5wVUCNdZv23aX/EdzArmFhl++kd49zr+c1taM4AmQDaK68zScBNOgPF3el FT14quqq6kH4qkZ0X7m4+r0H7j2kO5KNm6jvVX9Nn/dPKff+RWusXFVkARm7DNbARhui FGXVzTQfZlJYOsWG8ZZFVH1KGT/0mpBJIjhRr4b9QQfjisfBI+FNuYHUlItYi5K4pjlL mJBzN53CQHzeJSRr1goaRyXd5vfqq6sJzxIJBulMvhHnzhNccBje/+ZDHqW6ulE4nV4r vQEQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga23si10573974ejc.205.2021.07.19.04.49.33; Mon, 19 Jul 2021 04:49:56 -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; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236323AbhGSLHt (ORCPT + 99 others); Mon, 19 Jul 2021 07:07:49 -0400 Received: from mga01.intel.com ([192.55.52.88]:64303 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230493AbhGSLHs (ORCPT ); Mon, 19 Jul 2021 07:07:48 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10049"; a="232810505" X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="232810505" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2021 04:48:27 -0700 X-IronPort-AV: E=Sophos;i="5.84,252,1620716400"; d="scan'208";a="494039926" Received: from smile.fi.intel.com (HELO smile) ([10.237.68.40]) by fmsmga004-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 19 Jul 2021 04:48:25 -0700 Received: from andy by smile with local (Exim 4.94.2) (envelope-from ) id 1m5Rkw-00FUxJ-MN; Mon, 19 Jul 2021 14:48:18 +0300 Date: Mon, 19 Jul 2021 14:48:18 +0300 From: Andy Shevchenko To: Andrea Merello Cc: Jonathan Cameron , Lars-Peter Clausen , Rob Herring , Matt Ranostay , vlad.dogaru@intel.com, linux-kernel , linux-iio , Andrea Merello Subject: Re: [PATCH 2/4] iio: imu: add Bosch Sensortec BNO055 core driver Message-ID: References: <20210715141742.15072-1-andrea.merello@gmail.com> <20210715141742.15072-3-andrea.merello@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 19, 2021 at 11:02:07AM +0200, Andrea Merello wrote: > Il giorno gio 15 lug 2021 alle ore 18:50 Andy Shevchenko > ha scritto: > > > > > > +/* must be called in configuration mode */ > > > +int bno055_calibration_load(struct bno055_priv *priv, const struct firmware *fw) > > > +{ > > > + int i; > > > + unsigned int tmp; > > > + u8 cal[BNO055_CALDATA_LEN]; > > > + int read, tot_read = 0; > > > + int ret = 0; > > > + char *buf = kmalloc(fw->size + 1, GFP_KERNEL); > > > + > > > + if (!buf) > > > + return -ENOMEM; > > > + > > > + memcpy(buf, fw->data, fw->size); > > > > kmemdup() ? > > > > As a second thought: no, the whole point of reallocating and copying > here, is that we want to allocate an extra byte; kmemdup() will > allocate and copy only the very same amount of memory kmemdup_nul() then. -- With Best Regards, Andy Shevchenko