Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1553246rdd; Thu, 11 Jan 2024 02:41:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IEHTOPYMj7TX6jxMFOnZ6WXIe4joLl9hkpIzTDcc6pKWQ31aXMdEclWcxib3LVKlvttkPW/ X-Received: by 2002:a81:e344:0:b0:5ed:fb78:5b7a with SMTP id w4-20020a81e344000000b005edfb785b7amr339475ywl.14.1704969683750; Thu, 11 Jan 2024 02:41:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704969683; cv=none; d=google.com; s=arc-20160816; b=NKx0cxjAAoi+0goxUabzvL7gCaDsXaEbg1GZyZW/EPH7TJGswpvadVfVmSQ8Hq3qyx Yhv9N4jGHh4HmJJmUuA8SMZohqqCRRqB6fzmZd4IVf7YlZZBJf8tQOoay6Cv/hwrVgJY Rr1Hi6QVbvwz0OiIhE9NjvUulotfY6gRZbABWqGLfPLtabK/xFp8KR0K6VoDwzL3NsbN 3ts/2KA0pqGZhNl0Y266jCDzUJo1z3YovfzIZHcXgBJMiugZv72yEyNWZS0YTo3D45dx 6Zm7PJDO0y4rTS+y9U1cOOxA3zyqBppgErkelFB+mD6mAmlACDYlr+Mvt6nrUpAQIsa9 DWnw== 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=cIwO2uKfAqZlJZ6y6vQK56C4dKhJSBF6Q/Pydw7glWA=; fh=Of1//n5qgTiBIBqTw1K++F65AGqNu+3cgwYrG/S2rFM=; b=g0ML+zXNRGOW9NOF1d/rsBEucDUbEx99QgM15UfsD3f2iMCOwsth2V362zmRlyCB7C 0MB3RZF24X5jK89pUtZhMMnd13LeKklgkavnUg35pA86VCJvMXcXMRsIYyq3n8a/pSzI WzKqT/8fPnO+6Oam9t72vtqKQmBlVoRaYmee9rOlNxtw1r/3H8VSKD1gM/wLIURO4pTQ 5/gvxqWlrXw4+5YVlAs8kXdGYRjCP35lLo6HneozZYbpb4TLy0K1TTIs3qtTl6X/14WA FHJIGH8jBcLJOQr/DYfTqcQrNpRrkFkc9ddQutBRk1vKfbfiXl8dIQC9k8InHHCYzZJT bo1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=nVlwXkwb; spf=pass (google.com: domain of linux-kernel+bounces-23392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23392-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 h17-20020a05622a171100b00429c87ba96asi136727qtk.44.2024.01.11.02.41.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 02:41:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23392-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=nVlwXkwb; spf=pass (google.com: domain of linux-kernel+bounces-23392-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23392-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 7FD571C22444 for ; Thu, 11 Jan 2024 10:41:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1B12714ABD; Thu, 11 Jan 2024 10:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nVlwXkwb" 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 499A5EAC0; Thu, 11 Jan 2024 10:41:13 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 71DA9C433C7; Thu, 11 Jan 2024 10:41:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1704969673; bh=fNe+aOY4b9Ohw/Yu8Wsl7DvNtIa37fXz9HgdmlqWUYQ=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=nVlwXkwbcdzpDiLb0a4le3m+lK/cqZngojxbhtq4kaGnXTrZRUL/gWPZKZT8g8Vct FCVUxw4zpFA0wY652ZeEoeJ2t07hvd6wn7tf+VIciV3MaH8psqSnz4ehHiTxfD7lNw 8dJkxH6EymvAhBHt+XchKxOTeOQxxrb7mTGoGHZQ3BeqpjFtjDESAlnBKsMp0jr2Jy k2Mua/Kxr0zdca1ZNgtTLiVi9PPk9DuPliXXde5OuwgFaDFx7d9bP49ADO5a2b8wMO uJwJaiQbwaW1Qlx77d9DeOZAaQjzqGVSIc4/FliZUyCPwsaWg32hrMs7x4gSIQrrz4 PGuhMxYqRJjJA== Date: Thu, 11 Jan 2024 10:41:09 +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: [PATCH] leds: trigger: oneshot: One function call less in pattern_init() after error detection Message-ID: <20240111104109.GB1665043@google.com> References: 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: On Tue, 26 Dec 2023, Markus Elfring wrote: > From: Markus Elfring > Date: Tue, 26 Dec 2023 22:02:08 +0100 > > 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? > This issue was detected by using the Coccinelle software. > > Thus use another label. > > Signed-off-by: Markus Elfring > --- > drivers/leds/trigger/ledtrig-oneshot.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/leds/trigger/ledtrig-oneshot.c b/drivers/leds/trigger/ledtrig-oneshot.c > index bee3bd452abf..31061ec0afe6 100644 > --- a/drivers/leds/trigger/ledtrig-oneshot.c > +++ b/drivers/leds/trigger/ledtrig-oneshot.c > @@ -134,7 +134,7 @@ static void pattern_init(struct led_classdev *led_cdev) > > pattern = led_get_default_pattern(led_cdev, &size); > if (!pattern) > - goto out_default; > + goto out_settings; > > if (size != 2) { > dev_warn(led_cdev->dev, > @@ -151,6 +151,7 @@ static void pattern_init(struct led_classdev *led_cdev) > > out_default: > kfree(pattern); > +out_settings: > led_cdev->blink_delay_on = DEFAULT_DELAY; > led_cdev->blink_delay_off = DEFAULT_DELAY; > } > -- > 2.43.0 > -- Lee Jones [李琼斯]