Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp3656363rwb; Tue, 20 Sep 2022 02:48:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4HupnMLK7Nma9YvId0ApP6G+d3nLGMsoakRHaqKtWeCpsMnXShzRTZnSbQgkCOC/gBqBO+ X-Received: by 2002:a17:907:2d14:b0:779:fa1d:1aac with SMTP id gs20-20020a1709072d1400b00779fa1d1aacmr15984506ejc.585.1663667322853; Tue, 20 Sep 2022 02:48:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663667322; cv=none; d=google.com; s=arc-20160816; b=eqn3k2EYG58IhoGohQtz9KAuICrd3rU+PNEyvwVCI8CNUY10Fc075opQXlxyanYw4J ZozggS7mjBPIrh4v9NudJO/gmHovOHJ2t3aSV3TauqH5fONxy4wtkfd5MKdlyuO8g8r+ C0EyUGU+ipl3OBaLGHeDASqYdi4SP7QteYlTzRIh3xbTD7cyq6XJuKlm6Fm3E8jQiuHS wUfW0J4XIaT5/foAmshhK0R8gZHy6ArhE2HG7Ohdl9opcN9J6lo9Hk1VXVCoiR5yb8pG G7c4firZd4KjeC4nZ4FToiuGdGeLw9FnilAohIeTUOptBzmkbDeTeSgs6OsAPcZDMlTQ bpBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature; bh=9fZ0RB+YQJsI7wvjy0kGkFC/Dk3yABhSHQ7rieJRSLo=; b=BDGxOyJlnZPpb4g2iCe3tTGpmjFz0PdJcahfAsots8U+JA+6xObNgdaZwG8Q1+Wa0j V8XwPUCnBraEx7nWV/HkHmi97s3V5Pm8oiKAy8IYgZ5IA1exjlWYoiuiRiT9my63wXWS YpdGYx/Kl5w0b47IynlbwYRvnR6Z60AXx4gJqTwVo4f371esTAefq4uy+hOul/k1zH7F OEOaq6gHMnmAcTAOElEa9+7tqpckpxBf433Ob32J/u3ZNrnLrcrIYZ9sqNfZ7pRL7+I6 tiP6ZS65FSp2yjV+x6JltvotQkIdV87O4YwdTxPgOnPC/4N/wJv+WkknyL4fh3OdPiaU LxSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@posteo.de header.s=2017 header.b=SFW1NWbr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402278800b00450ed06bd86si1303774ede.619.2022.09.20.02.48.17; Tue, 20 Sep 2022 02:48:42 -0700 (PDT) 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; dkim=pass header.i=@posteo.de header.s=2017 header.b=SFW1NWbr; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=posteo.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229812AbiITJ2f (ORCPT + 99 others); Tue, 20 Sep 2022 05:28:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229695AbiITJ2d (ORCPT ); Tue, 20 Sep 2022 05:28:33 -0400 Received: from mout02.posteo.de (mout02.posteo.de [185.67.36.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD4ED6AA08 for ; Tue, 20 Sep 2022 02:28:31 -0700 (PDT) Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 60586240101 for ; Tue, 20 Sep 2022 11:28:30 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.de; s=2017; t=1663666110; bh=vHEP6vaM4hy2huTBhOW3ls1s8DRZuvLteUrEaol9UKs=; h=Subject:From:To:Cc:Date:From; b=SFW1NWbrvd0NIX9gO5dnfvdVVSQfYgnL05sqKzlHSWA0Ej99wDpZNBrzlfc06uzo1 iLzzr4rYmTk9b7MKxT0R9RTRhFnPp1dcvRmON/86VxFx/Zug62L57n+a0JwWw6kXCf vorM0DTJnAvqM+uhY9pQwEuzTQBi5AR0byihMUqhe5Cfu4KPAya+/RNyZT4AGFcM1o Cm44C9TQkBnxkq38fWw2X/rNvfhkiDAGvrk9YoQLKkT6bzuB8nDgaFzqXoQIFphJQr HeV5nYdZ4HahwDa3pQZYHkxCzZ523A8DX3WaGfH8kC6943skEcuCAbzDZDFlXrP9OC rQ8fHDwOw8jPA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MWx7053TKz6tmV; Tue, 20 Sep 2022 11:28:28 +0200 (CEST) Message-ID: <823a21b40a6ba6ccd022594c6bf1efaeb7a5a65d.camel@posteo.de> Subject: Re: [PATCH] media: i2c: hi846: Fix memory leak in hi846_parse_dt() From: Martin Kepplinger To: Rafael Mendonca , Mauro Carvalho Chehab , Sakari Ailus , Pavel Machek Cc: Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 20 Sep 2022 09:28:28 +0000 In-Reply-To: <20220919021252.730729-1-rafaelmendsr@gmail.com> References: <20220919021252.730729-1-rafaelmendsr@gmail.com> Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Am Sonntag, dem 18.09.2022 um 23:12 -0300 schrieb Rafael Mendonca: > If any of the checks related to the supported link frequencies fail, > then > the V4L2 fwnode resources don't get released before returning, which > leads > to a memleak. Fix this by properly freeing the V4L2 fwnode data in a > designated label. > > Fixes: e8c0882685f9 ("media: i2c: add driver for the SK Hynix Hi-846 > 8M pixel camera") > Signed-off-by: Rafael Mendonca > --- >  drivers/media/i2c/hi846.c | 14 ++++++++++---- >  1 file changed, 10 insertions(+), 4 deletions(-) > > diff --git a/drivers/media/i2c/hi846.c b/drivers/media/i2c/hi846.c > index ad35c3ff3611..254031503c72 100644 > --- a/drivers/media/i2c/hi846.c > +++ b/drivers/media/i2c/hi846.c > @@ -2008,22 +2008,24 @@ static int hi846_parse_dt(struct hi846 > *hi846, struct device *dev) >             bus_cfg.bus.mipi_csi2.num_data_lanes != 4) { >                 dev_err(dev, "number of CSI2 data lanes %d is not > supported", >                         bus_cfg.bus.mipi_csi2.num_data_lanes); > -               v4l2_fwnode_endpoint_free(&bus_cfg); > -               return -EINVAL; > +               ret = -EINVAL; > +               goto check_hwcfg_error; >         } >   >         hi846->nr_lanes = bus_cfg.bus.mipi_csi2.num_data_lanes; >   >         if (!bus_cfg.nr_of_link_frequencies) { >                 dev_err(dev, "link-frequency property not found in > DT\n"); > -               return -EINVAL; > +               ret = -EINVAL; > +               goto check_hwcfg_error; >         } >   >         /* Check that link frequences for all the modes are in device > tree */ >         fq = hi846_check_link_freqs(hi846, &bus_cfg); >         if (fq) { >                 dev_err(dev, "Link frequency of %lld is not > supported\n", fq); > -               return -EINVAL; > +               ret = -EINVAL; > +               goto check_hwcfg_error; >         } >   >         v4l2_fwnode_endpoint_free(&bus_cfg); > @@ -2044,6 +2046,10 @@ static int hi846_parse_dt(struct hi846 *hi846, > struct device *dev) >         } >   >         return 0; > + > +check_hwcfg_error: > +       v4l2_fwnode_endpoint_free(&bus_cfg); > +       return ret; >  } >   >  static int hi846_probe(struct i2c_client *client) thank you very much for the patch. lgtm, Reviewed-by: Martin Kepplinger martin