[{"id":3676550,"web_url":"http://patchwork.ozlabs.org/comment/3676550/","msgid":"<adynlKves3yAAcCA@stanley.mountain>","list_archive_url":null,"date":"2026-04-13T08:21:40","subject":"Re: [PATCH 4/5] staging: nvec: fix pm_power_off teardown in\n tegra_nvec_remove()","submitter":{"id":389,"url":"http://patchwork.ozlabs.org/api/people/389/","name":"Dan Carpenter","email":"error27@gmail.com"},"content":"On Sun, Apr 12, 2026 at 10:51:17PM +0200, Alexandru Hossu wrote:\n> The remove() function unconditionally sets pm_power_off to NULL regardless\n> of whether this driver instance was the one that set it. There is even a\n> FIXME comment acknowledging this. Additionally, nvec_power_handle is never\n> cleared on removal, leaving a dangling pointer to freed device data.\n> \n> Fix both issues: check that pm_power_off still points to nvec_power_off\n> before clearing it, and also clear nvec_power_handle at the same time.\n> \n> Signed-off-by: Alexandru Hossu <hossu.alexandru@gmail.com>\n> ---\n>  drivers/staging/nvec/nvec.c | 6 ++++--\n>  1 file changed, 4 insertions(+), 2 deletions(-)\n> \n> diff --git a/drivers/staging/nvec/nvec.c b/drivers/staging/nvec/nvec.c\n> index 75877038847f..9fe9b7a3491d 100644\n> --- a/drivers/staging/nvec/nvec.c\n> +++ b/drivers/staging/nvec/nvec.c\n> @@ -907,8 +907,10 @@ static void tegra_nvec_remove(struct platform_device *pdev)\n>  \tnvec_unregister_notifier(nvec, &nvec->nvec_status_notifier);\n>  \tcancel_work_sync(&nvec->rx_work);\n>  \tcancel_work_sync(&nvec->tx_work);\n> -\t/* FIXME: needs check whether nvec is responsible for power off */\n> -\tpm_power_off = NULL;\n> +\tif (pm_power_off == nvec_power_off) {\n> +\t\tpm_power_off = NULL;\n> +\t\tnvec_power_handle = NULL;\n> +\t}\n\nLinux power off handling is a known mess...\n\nI wonder why the original added a comment instead of a test?  To me\nchecking for if if (pm_power_off == nvec_power_off) makes sense and I\ncan't see how it would hurt anything.\n\nAt this point, we're unloading the driver so nvec_power_handle is\nabout to be freed.  Is there any benefit to setting it to NULL?\n\nregards,\ndan carpenter","headers":{"Return-Path":"\n <linux-tegra+bounces-13738-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-tegra@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256\n header.s=20251104 header.b=WsQWyFya;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.232.135.74; helo=sto.lore.kernel.org;\n envelope-from=linux-tegra+bounces-13738-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=\"WsQWyFya\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=209.85.128.45","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=gmail.com"],"Received":["from sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvL3j5P0dz1yDF\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 18:21:53 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sto.lore.kernel.org (Postfix) with ESMTP id D5FBB3001D4C\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 08:21:50 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 98A823A783B;\n\tMon, 13 Apr 2026 08:21:49 +0000 (UTC)","from mail-wm1-f45.google.com (mail-wm1-f45.google.com\n [209.85.128.45])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id A084C3A6B67\n\tfor <linux-tegra@vger.kernel.org>; Mon, 13 Apr 2026 08:21:47 +0000 (UTC)","by mail-wm1-f45.google.com with SMTP id\n 5b1f17b1804b1-488b0046078so40297275e9.1\n        for <linux-tegra@vger.kernel.org>;\n Mon, 13 Apr 2026 01:21:47 -0700 (PDT)","from localhost ([196.207.164.177])\n        by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-488d5934a6dsm305318865e9.11.2026.04.13.01.21.43\n        (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n        Mon, 13 Apr 2026 01:21:43 -0700 (PDT)"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776068509; cv=none;\n b=EDnwLbkiBD5hK2we7yY9Rtj82bJnYpOeF06vZ7ZpLokmzrNMt+m8vkFHTU8wer0LCQZdeO0PvdP66qe0YCX1N1UbkZCHHN/KA5cBFWOJH9jXy0h514sEg78wZkpI6uLvFoOpFqs2g+Yag9w+7/2LpCf6rt2YURnmAli3D/b9aHE=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776068509; c=relaxed/simple;\n\tbh=quZVGeXcNSTruvSPIgy79uCUxaqv3oB1d3yNl9q1uts=;\n\th=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version:\n\t Content-Type:Content-Disposition:In-Reply-To;\n b=oKulHtjQJ5HFxUn/+e+yjgLwJMq5sN411bOa+BsTuaTgSIrZDg/bGbFrWTfvgBJJjHfx71+OpMTx+pynPZMIsT0sEcnAts3jg77YqN56V1jp/sw0i1M1S5sp4TTZjMiJUU21U+jiOZLy7dbvUWUxD1HW8Di1EEkITYF4ppQGh4U=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=gmail.com;\n spf=pass smtp.mailfrom=gmail.com;\n dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com\n header.b=WsQWyFya; arc=none smtp.client-ip=209.85.128.45","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=gmail.com; s=20251104; t=1776068506; x=1776673306;\n darn=vger.kernel.org;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to;\n        bh=VxL7NBpm6fOiY9vFikulF9wM2xEFgsGl8u5ELNG6Df8=;\n        b=WsQWyFyadxdk+p8rSmCTaGlmmDtC2juXjHGMQbik8AhB/DcqWigBmMITpWsjl+vpVp\n         OY35HPgyq0I6IZ7l9L7aKSQ0kBDjRCcT6icuA3bNVevn4L3NC4m8wlyU1SvCuorn6aRK\n         P9PCoW/fbFf8NV7njSlyFZaVj/6CKMH+s9j8dNUQv92nBzBf1ubqwVcRBMdRE8RyJGks\n         vspn2ZsIRP98NFAx69PC+5arXDNvh1QcJpmIPxtNZfJX+G9zKOJdnbUtoV1GWTQgZDFF\n         JzCMbrXEC7STgJXaifAsEAahvFXLemwM+GHX9K6tjh309GrEGQ2IvEZOaXo8TiSv02It\n         GFaQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n        d=1e100.net; s=20251104; t=1776068506; x=1776673306;\n        h=in-reply-to:content-disposition:mime-version:references:message-id\n         :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc\n         :subject:date:message-id:reply-to;\n        bh=VxL7NBpm6fOiY9vFikulF9wM2xEFgsGl8u5ELNG6Df8=;\n        b=lfDt1gJUY3s0HchKjHGWa72pZizEIIvknkYRvl97xDg+JTAM5hWxp/yMCWyGgP4X/V\n         qeVR+mrwvmehLOxxnyUuRfEEVqo2xwr45BDrz+osYsDXygPx4u6mN+l01tqoQjIzyBgI\n         vd4xrufJwIeYmpVk6wX8Gw4Iu7wgddV3Blpp0esYsPyTz+wnvYvKkkLcCkByQz4h5iyL\n         rDRCrKg30leYLmu6vSb0R8CIP1++B0gWRPkarPCB7btgc+7lcyWxVvr/EUEC9YEmCu0+\n         LebKNVETrpl7xnlAezv8peL+2gJ6D1cUtCXS98Y/Pz4MZJjcaPciJVwNxtlVfzgBO3DP\n         LZMg==","X-Gm-Message-State":"AOJu0YyBjQPAGnzfbcq1ePwyDHL261IT6l4/pOcNy8FExMm/ut7t6hDG\n\tkOjB0KGzGox5rhH7a08Kv2SvkRB9P1C/3RTbvhkOMxKaKnuK2L43bsa3","X-Gm-Gg":"AeBDiesKTHZ30qjC5N7NGmYAXnjpVbE1sty4Lb3Npky1cLqHAc0uvj4veIuKE3vcuWI\n\tRTWLFaRPQCNECVFCDcinCaAv2QjNKpzwYWI0foN/DntU3VrjR4yO0stUgXvnQpuoT10SqlrsDp7\n\tTdQ6+05D15VzfZfyf0etRcWcS30kS+MXcL9VFGAvvJlVXNEh0sywcyegqPavY39mMkA9eDFvlYk\n\tJUa04wWvAED7iCkv2alWeRuLlzQwJhn1fC+ewlyvHDlyxNElI//D0g3KXUa9goQzFM0rqev+grH\n\tQJ/s3Yw4iEtUR1aWjDsLghBu/gt3kSfbPqrTjod9DkGvce6Ge23iOc46abytQ0yfO9Lt985yJV6\n\tToEfedOfl8Ts05AQ9rrEN/psgqjnnKXrtrHemKdtBG132UMRPIQdWbTdigdoRNctIRHyAN4LXyy\n\tuYmhPRQQRzcgcBuc6U4S0=","X-Received":"by 2002:a05:600c:8b30:b0:485:2f4a:6ae6 with SMTP id\n 5b1f17b1804b1-488d67bf79emr177041365e9.6.1776068505834;\n        Mon, 13 Apr 2026 01:21:45 -0700 (PDT)","Date":"Mon, 13 Apr 2026 11:21:40 +0300","From":"Dan Carpenter <error27@gmail.com>","To":"Alexandru Hossu <hossu.alexandru@gmail.com>","Cc":"linux-tegra@vger.kernel.org, marvin24@gmx.de,\n\tgregkh@linuxfoundation.org, linux-staging@lists.linux.dev,\n\tlinux-kernel@vger.kernel.org","Subject":"Re: [PATCH 4/5] staging: nvec: fix pm_power_off teardown in\n tegra_nvec_remove()","Message-ID":"<adynlKves3yAAcCA@stanley.mountain>","References":"<20260412205117.387125-1-hossu.alexandru@gmail.com>\n <20260412205117.387125-2-hossu.alexandru@gmail.com>","Precedence":"bulk","X-Mailing-List":"linux-tegra@vger.kernel.org","List-Id":"<linux-tegra.vger.kernel.org>","List-Subscribe":"<mailto:linux-tegra+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-tegra+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20260412205117.387125-2-hossu.alexandru@gmail.com>"}}]