Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp541860pxk; Wed, 23 Sep 2020 09:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4yx4yPzDZWA4tEw80eSjcCDXOVMbrFOb2EXPEi5E55EqKandO5wFeZpbKg9wI08zThayl X-Received: by 2002:aa7:cd06:: with SMTP id b6mr134863edw.196.1600878413006; Wed, 23 Sep 2020 09:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600878412; cv=none; d=google.com; s=arc-20160816; b=kniz9eJHlq5dJ+/tHeABKf5Qi7M3kUjlZP/tkvK5Kh7vrMaCUaZprfK3Jce/MRBGOQ TgZ6wyy4GBVLqCORrfdBnjPpmA+peKgWB3EWo0m+DC9OMxuMclPw3g1FntbmcEoevIGa pqswMwEEQC2IofC120Nma6VjLkHi1jdw/j+n4sGok2eb5JrtgTcoHc64SFIs6CA2Dh3j cPYTdNKrthaqdF5m1T4HDcz9CpLf7IrI+hww6aNZWPXLHnVsYBdETT0oDr0WXo1ZrDUn CleoTjaqdBdds8gQj8YNHkR/uUj9dvjtnTp0lE6A6+2W3UCCe5l/GGS5G73PiRpETPrv iWwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=TL550vpV9vvwO6gByxegQJTJCQglv96mFmOszOGj/Wc=; b=pQKgMQAx0bxfIPAUEuXneBa0RGqOqzVarqsRhguTo8wKkF0JEy6d3tvbC9188uQBPC NsPyvTr9rkqJkfuLvxR3N7xbiOvXV6jBkxSH6KO95isxBhMari77upWAGLCwG3hTNoSv VPMUpM5N0fsAw/+0cM9n+Ew2Sg7yesSJGnqDjeweBoluGPdVGba3wszGaG6kkjG20UBs DsB00bB7U3yrN6UNu7nRUFDbAxX4lq153W5mFUifSOywSL6Ww/tYO1RZ7uUzMlieBJqM UJkFENJQcLwU8QsRrWHMzaBumKtVd3myl2if5FonAPwCnJa62X6lmMuNS29BmQX89nN1 lVyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ueztojDb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c15si217255eds.227.2020.09.23.09.26.28; Wed, 23 Sep 2020 09:26:52 -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=pass header.i=@linaro.org header.s=google header.b=ueztojDb; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726668AbgIWQZJ (ORCPT + 99 others); Wed, 23 Sep 2020 12:25:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51220 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726184AbgIWQZJ (ORCPT ); Wed, 23 Sep 2020 12:25:09 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8C37C0613CE for ; Wed, 23 Sep 2020 09:25:08 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id c18so667534wrm.9 for ; Wed, 23 Sep 2020 09:25:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=TL550vpV9vvwO6gByxegQJTJCQglv96mFmOszOGj/Wc=; b=ueztojDbxMaO3ix3kcYHw8Uad1Exy3Z+VjV1Ll8+Qzidrealat7RoGozflgeOnbCQo B9vPyJkhVNzyfByquiRD8VRR6i+OdOrcf3WRv760j36aTFL+AZeLHhUrLEsnE7MrOMwb mdJE6VqeCtn42OxTRmUiYPlwkLB6L94mjIe3wscvMYPg2mXTnO/27cr+u06t9fFTArGE T5/3XZQ/dKaWyC1QlgYe5nQX59KKNA6pZ3aSUG4yiSza0K12NhAhCAKjZwROdwNUR+h4 GwFLOtLlOaKInpNF0Es/ZtxqCCjeUdfr2/1t8Qu5w/TwMTzX+Si9oWxkpezBYZTEQG1P 87Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=TL550vpV9vvwO6gByxegQJTJCQglv96mFmOszOGj/Wc=; b=M2YkxhhZh4v2gSeZ64gbvwwQgOm2pFOXgmfAMl1ZkTpaDZqPFdSfaEdw65GqmCvp3U EQJsudfC9NEmzgOIlor8HUcpHxKWV+gjjnYMf+tEtQKHtvju5n/eQ/aXxcvj/4qZcRvb I/1YMmvvjtVaB3d7VuUiU9F1lwT32wYXJK6Ur3oHmWB9E4Jt/Cwh2mBU7rnUXoXq+SI+ eGRCMQyHaLSd1jxK5Rg91zAVPsUaPuCXR+An88SkJTsSWgWZC9gjHCQ+jSA1jzktLzZP VlmprMUwe30cPJwfEQAJ8qd4ZitH83rBXiGTuLHlDohdE8N3vfA86UnKKxwlQ/DtkCPj XWRA== X-Gm-Message-State: AOAM531gkh10Ds8MAsAfRSKO6HQg+RtmT8rnYAYVOFzbOnxRUTv7ei9i lglpZkdlXRM8oTCgMwtX2GvKH9oStmGFXA== X-Received: by 2002:a5d:554c:: with SMTP id g12mr490819wrw.294.1600878307105; Wed, 23 Sep 2020 09:25:07 -0700 (PDT) Received: from [192.168.86.34] (cpc86377-aztw32-2-0-cust226.18-1.cable.virginm.net. [92.233.226.227]) by smtp.googlemail.com with ESMTPSA id g12sm290449wro.89.2020.09.23.09.25.06 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 23 Sep 2020 09:25:06 -0700 (PDT) Subject: Re: [PATCH v2] nvmem: core: fix possibly memleak when use nvmem_cell_info_to_nvmem_cell() To: Vadym Kochan Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org References: <20200923135343.16565-1-vadym.kochan@plvision.eu> <7a072204-a4b8-e5ef-9ce2-4db176f70366@linaro.org> <20200923141334.GA16798@plvision.eu> <1f65dc6a-50f3-d4e5-f1ce-7a68fddde287@linaro.org> <20200923145107.GB16798@plvision.eu> <19c5fa23-41c9-f5c7-beaf-aeb9655bfefd@linaro.org> <20200923162314.GF16798@plvision.eu> From: Srinivas Kandagatla Message-ID: Date: Wed, 23 Sep 2020 17:25:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20200923162314.GF16798@plvision.eu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/09/2020 17:23, Vadym Kochan wrote: > On Wed, Sep 23, 2020 at 04:51:06PM +0100, Srinivas Kandagatla wrote: >> >> >> On 23/09/2020 15:51, Vadym Kochan wrote: >>>> - return nvmem_cell_write(&cell, buf, cell.bytes); >>>> + rc = nvmem_cell_write(&cell, buf, cell.bytes); >>>> + if (rc) >>>> + kfree_const(cell->name); >>>> + >>>> + return rc; >>>> } >>>> EXPORT_SYMBOL_GPL(nvmem_device_cell_write); >>>> ------------------------>cut<--------------------------- >>>> >>>> --srini >>>> >>> But is it really needed to kstrdup(cell->name) for nvmem_device_cell_{read,write} ? >> This boils down to if we want to use same api to parse nvmem_cell_info or >> not! >> >> If we want to keep this simple, we can either explicitly add free for >> successful caller to nvmem_cell_info_to_nvmem_cell()! >> >> Or >> >> use something like what you did, but new api needs more clarity! >> May be renaming __nvmem_cell_info_to_nvmem_cell to >> nvmem_cell_info_to_nvmem_cell_no_alloc would clarify that a bit! >> > > Naming is most difficult thing, what about __nvmem_cell_info_to_nvmem_cell_{unsafe,nodup}() ? > At least this is an indication to be carefully here. nvmem_cell_info_to_nvmem_cell_nodup() should be good! --srini > >> Also can you make sure that linewrapping on function names be inline with >> existing code. >> >> Please send v3 with that changes! >> >> >> --srini >>> It is used only for log error in case the unaligned access did not >>> pass the check