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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 81227C43219 for ; Mon, 21 Nov 2022 07:52:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbiKUHwB (ORCPT ); Mon, 21 Nov 2022 02:52:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229794AbiKUHv7 (ORCPT ); Mon, 21 Nov 2022 02:51:59 -0500 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4963B31DC2 for ; Sun, 20 Nov 2022 23:51:58 -0800 (PST) Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ox1ak-0002dr-1P; Mon, 21 Nov 2022 08:51:46 +0100 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ox1ai-00058n-B2; Mon, 21 Nov 2022 08:51:44 +0100 Date: Mon, 21 Nov 2022 08:51:44 +0100 To: Michael Walle Cc: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 17/18] nvmem: layouts: Add ONIE tlv layout driver Message-ID: <20221121075144.GL3143@pengutronix.de> References: <20221118185118.1190044-1-michael@walle.cc> <20221118185118.1190044-18-michael@walle.cc> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221118185118.1190044-18-michael@walle.cc> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) From: Sascha Hauer X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 18, 2022 at 07:51:17PM +0100, Michael Walle wrote: > From: Miquel Raynal > > This layout applies no top of any non volatile storage device containing s/no/on/ > + table_len = hdr_len + data_len; > + if (table_len > ONIE_TLV_MAX_LEN) { > + dev_err(dev, "Invalid ONIE TLV data length\n"); > + return -EINVAL; > + } > + > + table = devm_kmalloc(dev, table_len, GFP_KERNEL); > + if (!table) > + return -ENOMEM; > + > + ret = nvmem_device_read(nvmem, 0, table_len, table); > + if (ret != table_len) > + goto free_data_buf; > + > + if (!onie_tlv_crc_is_valid(dev, table_len, table)) { > + ret = -EINVAL; > + goto free_data_buf; > + } > + > + data = table + hdr_len; > + ret = onie_tlv_add_cells(dev, nvmem, data_len, data); > + if (ret) > + goto free_data_buf; > + > +free_data_buf: > + kfree(table); This is allocated with devm_kmalloc(), you shouldn't free it here. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A0767C4332F for ; Mon, 21 Nov 2022 07:53:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:From:In-Reply-To:MIME-Version: References:Message-ID:Subject:Cc:To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Wfa/DdsBhVrr+LTVm+FRuZDmnznjjIMfy+IFGPv+MMI=; b=jOL9dLxqfVvgCXElLUDjm3KR+e UvUpVHCCNrjNCXBqH9s3Yl9YQ6MbZzHP19LtWdH6ZjnV5FMeDAgdn00ncAWZ6A0R2etyY2Si6vKhm IOwYkJ3twXbbQUq2hzE+hYmxfvWiGAfK0tOOV0zsG23iB3AYbDO2/7nvJ0wljmRArvsGNhzqXrnPd IiqUyqhUonvbpFwuzfpPSx6U+tUNIziKpCwm0hvyCTUtpO4Bh/WzFFHRMIQgHyTG7RRMhYuG/wCwJ C1X6goJUOWJJ4HA3N3H3mEvifyS98SgYJF368l4+lovJhUWdaessx3jp/vjqbTiWj3+N7/bJk+uTr CGkD0Qkw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox1b0-00AcXj-Lk; Mon, 21 Nov 2022 07:52:02 +0000 Received: from metis.ext.pengutronix.de ([2001:67c:670:201:290:27ff:fe1d:cc33]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ox1au-00AcOz-4R for linux-arm-kernel@lists.infradead.org; Mon, 21 Nov 2022 07:51:58 +0000 Received: from ptx.hi.pengutronix.de ([2001:67c:670:100:1d::c0]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ox1ak-0002dr-1P; Mon, 21 Nov 2022 08:51:46 +0100 Received: from sha by ptx.hi.pengutronix.de with local (Exim 4.92) (envelope-from ) id 1ox1ai-00058n-B2; Mon, 21 Nov 2022 08:51:44 +0100 Date: Mon, 21 Nov 2022 08:51:44 +0100 To: Michael Walle Cc: Jonathan Corbet , Srinivas Kandagatla , Miquel Raynal , Rob Herring , Frank Rowand , linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org Subject: Re: [PATCH v3 17/18] nvmem: layouts: Add ONIE tlv layout driver Message-ID: <20221121075144.GL3143@pengutronix.de> References: <20221118185118.1190044-1-michael@walle.cc> <20221118185118.1190044-18-michael@walle.cc> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20221118185118.1190044-18-michael@walle.cc> X-Sent-From: Pengutronix Hildesheim X-URL: http://www.pengutronix.de/ X-Accept-Language: de,en X-Accept-Content-Type: text/plain User-Agent: Mutt/1.10.1 (2018-07-13) From: Sascha Hauer X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-arm-kernel@lists.infradead.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221120_235156_220012_23907DE4 X-CRM114-Status: GOOD ( 17.94 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Fri, Nov 18, 2022 at 07:51:17PM +0100, Michael Walle wrote: > From: Miquel Raynal > > This layout applies no top of any non volatile storage device containing s/no/on/ > + table_len = hdr_len + data_len; > + if (table_len > ONIE_TLV_MAX_LEN) { > + dev_err(dev, "Invalid ONIE TLV data length\n"); > + return -EINVAL; > + } > + > + table = devm_kmalloc(dev, table_len, GFP_KERNEL); > + if (!table) > + return -ENOMEM; > + > + ret = nvmem_device_read(nvmem, 0, table_len, table); > + if (ret != table_len) > + goto free_data_buf; > + > + if (!onie_tlv_crc_is_valid(dev, table_len, table)) { > + ret = -EINVAL; > + goto free_data_buf; > + } > + > + data = table + hdr_len; > + ret = onie_tlv_add_cells(dev, nvmem, data_len, data); > + if (ret) > + goto free_data_buf; > + > +free_data_buf: > + kfree(table); This is allocated with devm_kmalloc(), you shouldn't free it here. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel