Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFD3EC433EF for ; Mon, 13 Dec 2021 10:25:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242921AbhLMKZM (ORCPT ); Mon, 13 Dec 2021 05:25:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244940AbhLMKUz (ORCPT ); Mon, 13 Dec 2021 05:20:55 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCA0EC094259; Mon, 13 Dec 2021 01:58:29 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id A4CCFB80E81; Mon, 13 Dec 2021 09:58:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AFEDEC34600; Mon, 13 Dec 2021 09:58:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1639389507; bh=bP/mCHnNWJSVWTol0xxFMwMXmjI10uo99AR0u52iLIY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s/6zh5QKOnnGlmLBZTzJ4oxwn8DwvSxY/PlHqCuhi/uHKBHHdcH41UZgzVgcUu6Io +kTFUC6s5rWIzTVfUvpTP8/pYWYyOc7IW8SZdPpGf1cdz32wCaB3jxAYZbpfRlTjY2 xZuKAnKuqAqpKlj0QWrc2EV03YpBKyMwZOkS6LzI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Armin Wolf , =?UTF-8?q?Pali=20Roh=C3=A1r?= , Guenter Roeck Subject: [PATCH 5.15 115/171] hwmon: (dell-smm) Fix warning on /proc/i8k creation error Date: Mon, 13 Dec 2021 10:30:30 +0100 Message-Id: <20211213092948.930278387@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20211213092945.091487407@linuxfoundation.org> References: <20211213092945.091487407@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: Armin Wolf commit dbd3e6eaf3d813939b28e8a66e29d81cdc836445 upstream. The removal function is called regardless of whether /proc/i8k was created successfully or not, the later causing a WARN() on module removal. Fix that by only registering the removal function if /proc/i8k was created successfully. Tested on a Inspiron 3505. Fixes: 039ae58503f3 ("hwmon: Allow to compile dell-smm-hwmon driver without /proc/i8k") Signed-off-by: Armin Wolf Acked-by: Pali Rohár Link: https://lore.kernel.org/r/20211112171440.59006-1-W_Armin@gmx.de Signed-off-by: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- drivers/hwmon/dell-smm-hwmon.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) --- a/drivers/hwmon/dell-smm-hwmon.c +++ b/drivers/hwmon/dell-smm-hwmon.c @@ -623,10 +623,9 @@ static void __init i8k_init_procfs(struc { struct dell_smm_data *data = dev_get_drvdata(dev); - /* Register the proc entry */ - proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data); - - devm_add_action_or_reset(dev, i8k_exit_procfs, NULL); + /* Only register exit function if creation was successful */ + if (proc_create_data("i8k", 0, NULL, &i8k_proc_ops, data)) + devm_add_action_or_reset(dev, i8k_exit_procfs, NULL); } #else