Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3125652pxv; Mon, 12 Jul 2021 09:52:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8VYeevuBOLj2Lhzv/eS4bar6PbE6V2SuZBB136FjzomRWk9RnZMCMG2Trrrb3pskOEgjy X-Received: by 2002:a17:907:3d8a:: with SMTP id he10mr55820ejc.16.1626108750307; Mon, 12 Jul 2021 09:52:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626108750; cv=none; d=google.com; s=arc-20160816; b=QdHdn1Y7XXzc7dCMdbBbpW3qNRJ+UgfjPcyLxlR5oTBR1UJVinpx4SVL3iZ3egKek/ cSS2PATtQ4MY9AXGpgNmNJRPxJVki9OAWyiDH/Ak16CXrafUz8L9z0TqV1kt/I0RFNNb LTAkURY9HZ8J6HEBeUJzwdGlu4YDebQVGV7QjHm/OBpaCU4py6k7goz76Bd+HiWuXyPv RBniGzZhw4EakwBEiuouTN+CVrzKHlxYfCKtVmbb5mp+dq8Q4j5Qdep8iTutc3jqo0Gd S7K85nBM6wwOdlj5iwNg7P0YSrUasDjWfCdel4zEL9l2+UVDlqMJBPpcn4rDln6znUia vfYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=8Wdadal12rIGNNPBqUS9wD/chlNAf1ptfZoPwkJaGrY=; b=tujxsi1lkkiM+yqXZvGO9e26hSTZ/d6JErh/1DyneDmV/JQnw/lH5E/itsQhC1aULT xZZXfiK8SeecjIDl8M9Ut1nt/2VevpeIqtRF0SfjtPt4vxKZK1ydjK/uLtzdo7No0v1R ryHx3BoSFtvnNWnEppVVdFT6EP3cPtQyyeAytNvPBBfgFGZYudLSHrSrj/ZuhJ4aE9lt wH4qnwfvugfqXwC+S4J8KAJzzMWxY8iCARogSryk+wJANSG6lUaNOe2MD4+qIJ/93/Ps 7+bLqrfUiQi5hczKgVwOBb4ylsBWdtNMAct7kRtlBIXlxepYD6Uo6arfwLMVdwGfwu1s k3Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=pieGt0ks; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rh9si15515624ejb.651.2021.07.12.09.52.06; Mon, 12 Jul 2021 09:52:30 -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 (test mode) header.i=@ideasonboard.com header.s=mail header.b=pieGt0ks; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234266AbhGLQxm (ORCPT + 99 others); Mon, 12 Jul 2021 12:53:42 -0400 Received: from perceval.ideasonboard.com ([213.167.242.64]:56116 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232710AbhGLQxl (ORCPT ); Mon, 12 Jul 2021 12:53:41 -0400 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 33622CC; Mon, 12 Jul 2021 18:50:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626108651; bh=+t8lSKMlrb/3E4DhDYLs266oy4TOU8BHEmxESYaNt8I=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=pieGt0ks0vsh7tOXCU6EM+lcz8G3MzzFccBJJnT/b5ufqCCDusGqc2R5SuqS5//29 pHi/RuF7RFsy5Kk37tHBmOO25wApXpjMXrepmesbJpg8L9UV+eMlx6Opni6mcpNKIB WHpc0Eb8LZOJgfZ4tpeSrSIY4PB0jwf/T5qW8Dj4= Date: Mon, 12 Jul 2021 19:50:04 +0300 From: Laurent Pinchart To: Steven Price Cc: Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, Biju Das Subject: Re: [PATCH] drm/of: free the iterator object on failure Message-ID: References: <20210712155758.48286-1-steven.price@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20210712155758.48286-1-steven.price@arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Steven, Thank you for the patch. On Mon, Jul 12, 2021 at 04:57:58PM +0100, Steven Price wrote: > When bailing out due to the sanity check the iterator value needs to be > freed because the early return prevents for_each_child_of_node() from > doing the dereference itself. > > Fixes: 4ee48cc5586b ("drm: of: Fix double-free bug") I don't think the Fixes tag is correct, the issue was already present before 4ee48cc5586b. The fix looks right though. > Signed-off-by: Steven Price > --- > drivers/gpu/drm/drm_of.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > Daniel's email[1] made me take a look at this function and it appears > that for_each_child_of_node()'s interface had caused a bad bug fix due > to the hidden reference counting in the iterator. > > [1] https://lore.kernel.org/r/YOxQ5TbkNrqCGBDJ%40phenom.ffwll.local > > diff --git a/drivers/gpu/drm/drm_of.c b/drivers/gpu/drm/drm_of.c > index 197c57477344..997b8827fed2 100644 > --- a/drivers/gpu/drm/drm_of.c > +++ b/drivers/gpu/drm/drm_of.c > @@ -331,8 +331,10 @@ static int drm_of_lvds_get_remote_pixels_type( > * configurations by passing the endpoints explicitly to > * drm_of_lvds_get_dual_link_pixel_order(). > */ > - if (!current_pt || pixels_type != current_pt) > + if (!current_pt || pixels_type != current_pt) { > + of_node_put(endpoint); > return -EINVAL; > + } > } > > return pixels_type; -- Regards, Laurent Pinchart