Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3861549rwb; Sun, 20 Nov 2022 23:56:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6zjzRx53AfmchpKqKDDc1WTr4QD8EANby2muV2LS8gOhZRfZS7y6UPhjjPWmx8vRJYRzW/ X-Received: by 2002:a17:907:9856:b0:780:8144:a41f with SMTP id jj22-20020a170907985600b007808144a41fmr14766403ejc.189.1669017378920; Sun, 20 Nov 2022 23:56:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669017378; cv=none; d=google.com; s=arc-20160816; b=DyT3Avo2hBug4uJy1wsEBkD3+mohi32YybF2VDatO9h6D4/1NtHYITmLilvjyrM8JM 02VgYccxizyX+xuymrMQT0YjR9lqKAO7HbeoERiR96y4S4Br5TxxegNc1FZwAbVi6err IHsqSauFBh/Gn1Hb1gitq/ucLo4CUwWegmLxnXKxBOPjjWmiNzCNgCvd8J3/dz/wqfmO hemJsHbPyxS5zTvWnBXLSbQBK5C2w3CuTtVWdR/Bg6RWHhU3A1hFXCHCu2MXxwmUQbTf 3AumIrOkCV2xH29rQLWIKmQ5eSOlH7RA4xDehoYUUFRDzRCewpRKM6CPNSg6EkLSjbvG b5Zg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:from:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:date; bh=FYtQSzqCVqiF0QLD/Mv13jZ2ne58tivHkOJw+FcFZjY=; b=KvISbt+LB5PFDCI3B3CKYbGJApv/WmIAau7/U7qfIcelR2/YPBDuZMBhPGimZlhcjs IenlCh2cQMLdl6319gCGMKQtG5jyh+3x6ZQETFqkRnQEyT3FrqZANKAklCRBywomtLAO Z9g1UP/QubeVCgFEbHslc3EnEYb7+CD/iaamZcU48KiGrTcXEPjpcyB+ZBh9VffnHl8c mEwyvoGEvXJmN27kt3iSNMwzXP00rDyCk44z95EpfYdz61y4wOOWlv2xLHGZcWYkjYjo Wm/iIN+G1rSwISBtTDwcA41b4Dx93R9CS2E9AOy+yr0208WOAdVUZ1MgBW4ijpjiId2G P1dQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xe14-20020a170907318e00b007ae417013desi9599025ejb.324.2022.11.20.23.55.56; Sun, 20 Nov 2022 23:56:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229724AbiKUHwA (ORCPT + 92 others); Mon, 21 Nov 2022 02:52:00 -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 X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 |