Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1629486rdd; Thu, 11 Jan 2024 05:06:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFTm3U6ADuhQ1mPIxzq9zRBgm60NJdL6FBPcB3UacPlJ0UFZoExnbY3LZHzmQRVh/LeytE5 X-Received: by 2002:a37:ac1a:0:b0:783:3dae:c55f with SMTP id e26-20020a37ac1a000000b007833daec55fmr1250110qkm.50.1704978394700; Thu, 11 Jan 2024 05:06:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704978394; cv=none; d=google.com; s=arc-20160816; b=LNqFI09k4pIvL3gSrrfCJjHhoJpR/7PT7fl2gFRzGW8gjVr+dPfu5DVp5BoC9kaBFc XPggc9m5QgOCFaAaSlvrQfKgyB9sMudJYWy2vB3MGzCd9xMd//mhEDEHkk5H73hb7GtG 1lXnKhoCsyZnSGlsNXOpJqsfkMqiITQ41on9vQwho/SIHHrYnOJqWwyGvIVDuCiUZfsV s2MGHIaHjAdUah11EV4OhKn7j/rxgRZAooUN9z2/d4Axydb/pqoA+vBPQKhUSZZyW4Jh r6qdrktHjvvBhqn+wlpaD3Ac8qyIhZoSGeqYfZUQ8yLgpUwJh8ZA49tFntOnUOxlILDZ AQfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0tDx2Qa9Hw46YOxwP2orKmW5+QaQa5KVupBNu31IE4A=; fh=Of1//n5qgTiBIBqTw1K++F65AGqNu+3cgwYrG/S2rFM=; b=nSF5kS9DertudEA2aCrh6FYfYQKufxa7uiUV8xzHmMN+IHIwDV86lFrsYO3R/qqpu1 T7xm2v2+jEQwlMBJRfjxuT6d9bjREVJth9Nmh3giDWMITgzI38WOO39QToCfqq6D/r01 IqL29vufRKwuI5QT+WQvjnjpklfNZUhgGIcyFBpp7jy6Hu8NsXrP5RraIJZ1YidBIBJM Lu1UmlnPqNpis5gzH/pnYsToFCzn+GtQgpf4sSZ8WRmZ21GbqWF5JTgwMKC+3+Z+CeJ4 Ea/OKX/U/11bF8gCR8tQzIE5WYJeLnrvBU9y6Chs/JW7WUFF9SQ4p7M9Usp499+sE9lC 29Hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDizyBTT; spf=pass (google.com: domain of linux-kernel+bounces-23618-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23618-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id b14-20020ac85bce000000b00429c9c5b56esi22203qtb.3.2024.01.11.05.06.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 05:06:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23618-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=MDizyBTT; spf=pass (google.com: domain of linux-kernel+bounces-23618-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23618-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id D14011C2202B for ; Thu, 11 Jan 2024 13:06:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0344215EA1; Thu, 11 Jan 2024 13:05:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="MDizyBTT" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2F0CC15E95; Thu, 11 Jan 2024 13:05:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 45B3CC433F1; Thu, 11 Jan 2024 13:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704978317; bh=7+NXqXzNwrtcAjYwpfHcy7Mr4As+DOX24vXMzISRV0Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=MDizyBTT4lUdyw6rCv8zKAHmwqw9LtW27IVv7dKksbPQeC9Z3oqWMmOjn390dkdzZ kPoNfFQzA48DhuvJf64lXaH7VWrSstpy0HFl4FAdAqvNSONMfe+oaXS/oulgj4zU+c yV5apq4uwFRh4xInD/ZE11WR0k7ClBu3NUU+iReeosAHgyXf58pMnL2F/28BWievZS Uwp3RNTMBAABpRXRqlcoGx5V5qcrib+f7kEbu5IrO4DovdzWhOS2I85EjCXEXqZ9Go d5e1WW6ruE5t8YmUTorzrYjhvsWuP8CtPSo8zSNX0fh0ZfFij6vxjEMJvAcSL+xj57 8UpB5XJGRSIzQ== Date: Thu, 11 Jan 2024 13:05:13 +0000 From: Lee Jones To: Markus Elfring Cc: linux-leds@vger.kernel.org, kernel-janitors@vger.kernel.org, Pavel Machek , LKML , cocci@inria.fr Subject: Re: leds: trigger: oneshot: One function call less in pattern_init() after error detection Message-ID: <20240111130513.GK1678981@google.com> References: <20240111104109.GB1665043@google.com> <58d6b9d0-a2d6-4d8d-bc36-fe783839ca79@web.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <58d6b9d0-a2d6-4d8d-bc36-fe783839ca79@web.de> On Thu, 11 Jan 2024, Markus Elfring wrote: > >> The kfree() function was called in one case by > >> the pattern_init() function during error handling > >> even if the passed variable contained a null pointer. > > > > It's totally valid to call kfree() on a NULL pointer: > > > > * If @object is NULL, no operation is performed. > > > > Why do we care all that much? > > Would you dare to categorise such special function calls as redundant? > > Should they be skipped in more cases? > > See also: > https://wiki.sei.cmu.edu/confluence/display/c/MEM12-C.+Consider+using+a+goto+chain+when+leaving+a+function+on+error+when+using+and+releasing+resources I have no idea what you're trying to say. The premise of your patch is based on the fact that we shouldn't call kfree() with a NULL pointer. When in actual fact kfree() is more than capable of handling cases where the passed object is NULL, and goes as far as to document as such. Meaning that unless I'm convinced otherwise, patches like this remain in the category of churn. -- Lee Jones [李琼斯]