From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.7 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9620AC07E9B for ; Mon, 19 Jul 2021 11:48:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5D80B60200 for ; Mon, 19 Jul 2021 11:48:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236469AbhGSLHu (ORCPT ); Mon, 19 Jul 2021 07:07:50 -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