Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4593115pxj; Wed, 12 May 2021 08:52:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKdJ9nGkv5QHMneJRuQE2a3CCY/cFSBV3hmlOotKxS5S6LUQOgevnFJ2XvRttb7FJL8lXH X-Received: by 2002:a17:906:158c:: with SMTP id k12mr15859772ejd.274.1620834752916; Wed, 12 May 2021 08:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834752; cv=none; d=google.com; s=arc-20160816; b=V3PpmOtGurfI5T1dXa7lkK/dMsKahrTs/vsE/xAb5H73Lm1qltG5OhRXkJIbDMVKRq XhKh+DcqTK4BfnhTsI3cywR9Rx4VbvK0ypvZ2X87YTXKDy8sNrGBJo4GaS1LIMUXYijv GOqlvFE25TIvcGV4iGaq7WDDyzyhpRie/44alXsN0mjplysNDUTctedW66Mdne+pgzhR hR+1/L2MI1uuXh1L3p/hXMKvJ1PddIXdzUof7LGax8nDqRSlbHrZykpPDEE+VATKvXYf rHr5Bzf2jXVNcszwKFDfTKOfEJEjrOBRuWdD+hjp3EYpCs+BTWOt9MeFRh4m9by541Ni 32+A== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=KkgIrra1fsVeloi4R3y0wl9UNjayW24z3/1sww/9TI8=; b=t8NO0HKncZWs9h+GKKAmvDsjViFl5R/oiUAfgXTh2E7VMx/tbRCUFiPJiLpT5WNqC5 7hEoUMLI0LzemiGK90Yd2KIAwZoXm4KnYzrxL+W/bL6GT7p8gMLgwX3BuD7AMfSEfME3 IqTDiN3bYeBY8hL1BDrCQ2IP6Pnd6nD1K/9vhmbVrPrWN+MTKnJ/KmabgS3ECXB7enp7 fe7jFxkrUT+w7y5xiq+Tgd4EPk9BEMZhFc1yJIOvlqanFcW+wrYqqeAedGIq4kddxrqQ c2yvSKbUJOENnF0KvWhE3MV8VraPW9e2EmraZyPQIQL6p/rX9RfX467OQublU67yUAWj mhEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=PHO2lkvl; 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id rs10si287334ejb.93.2021.05.12.08.52.06; Wed, 12 May 2021 08:52:32 -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=@linuxfoundation.org header.s=korg header.b=PHO2lkvl; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236681AbhELPpp (ORCPT + 99 others); Wed, 12 May 2021 11:45:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:60686 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234689AbhELPUY (ORCPT ); Wed, 12 May 2021 11:20:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 950C360FD9; Wed, 12 May 2021 15:08:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832109; bh=RUzs8sveTmYzQCIE7RnOZxqCzs+u8mJGuskzNLjrQsI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PHO2lkvlHyXHv1s+1s4jS7EQ07fHH/MN4sqhFYCvQqREVHHayKbpoEm8zYZ0SOebS qXEp/8Y7bSzkr3qZzaEnmOMRFglgTYnGZ+J3ayleKA6brdzahUFrV3TdqZg8G5v+j7 1FNxK7iaoRoA7l3/FsPRo7teFjiLvATjl/c7WzU4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , Dan Carpenter , Tejas Patel , Rajan Vaja , Michal Simek , Sasha Levin Subject: [PATCH 5.10 111/530] firmware: xilinx: Fix dereferencing freed memory Date: Wed, 12 May 2021 16:43:41 +0200 Message-Id: <20210512144823.446878401@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tejas Patel [ Upstream commit f1f21bece82c76a56a96988ec7d51ccc033d8949 ] Fix smatch warning: drivers/firmware/xilinx/zynqmp.c:1288 zynqmp_firmware_remove() error: dereferencing freed memory 'feature_data' Use hash_for_each_safe for safe removal of hash entry. Fixes: acfdd18591ea ("firmware: xilinx: Use hash-table for api feature check") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Tejas Patel Signed-off-by: Rajan Vaja Link: https://lore.kernel.org/r/1612765883-22018-1-git-send-email-rajan.vaja@xilinx.com Signed-off-by: Michal Simek Signed-off-by: Sasha Levin --- drivers/firmware/xilinx/zynqmp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index fd95edeb702b..9e6504592646 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -2,7 +2,7 @@ /* * Xilinx Zynq MPSoC Firmware layer * - * Copyright (C) 2014-2020 Xilinx, Inc. + * Copyright (C) 2014-2021 Xilinx, Inc. * * Michal Simek * Davorin Mista @@ -1280,12 +1280,13 @@ static int zynqmp_firmware_probe(struct platform_device *pdev) static int zynqmp_firmware_remove(struct platform_device *pdev) { struct pm_api_feature_data *feature_data; + struct hlist_node *tmp; int i; mfd_remove_devices(&pdev->dev); zynqmp_pm_api_debugfs_exit(); - hash_for_each(pm_api_features_map, i, feature_data, hentry) { + hash_for_each_safe(pm_api_features_map, i, tmp, feature_data, hentry) { hash_del(&feature_data->hentry); kfree(feature_data); } -- 2.30.2