From mboxrd@z Thu Jan 1 00:00:00 1970 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 8776E1BC3C for ; Sun, 15 Sep 2024 13:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726405233; cv=none; b=kp5qOAofjraO3ymmj/1HLRwM9In7jqNEDkGom/4niaH/SQqB6UukSm56oavN27Vs5HmwGXP/YkQrybVAq+zD/kBOsRHqimhx2vkPi/RJ4W+x38pOUf7ce7PidvkBTgofGio/hWITPl0zUJDoQ0z64ZfhN0+0SBkaSyKVN1Wm/6g= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1726405233; c=relaxed/simple; bh=zirVz6Gl8tXxG4TwpWPeqZw7VukqKnslPlo0KX14Po0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=kvO/amAYbgoCLxrMob3JLVExCKG1fqk9qjsBtw+LAr6HpUXy7BNO48WfEAviMK0UBtcBXFeC6g6Y5opf5VxHumiEXDsHNKb9VK1J7tcpwWKT+ORiuqCwUerenBoyuqf+nbX7HsN9P/nxAO/DtLBiYiJZSJZtRiup7V650GHefjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=rO92kfW3; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="rO92kfW3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87C26C4CEC3; Sun, 15 Sep 2024 13:00:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1726405232; bh=zirVz6Gl8tXxG4TwpWPeqZw7VukqKnslPlo0KX14Po0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=rO92kfW3F21Iw2+eaBF94mOOlBj4A4iy5wwBoGQ71FmTsUiYSFbSLYogUN6RegFJE DGmeGOvdmt899EvT8aeL8Cy69Mdgy7G4DQhmevjtcg1ms+GT1KXJWQiLV2pwdcSIDS tMLrVkWlrykqhHtxpWKrQhPwE3HYNKG4roHUsI5Q= Date: Sun, 15 Sep 2024 15:00:27 +0200 From: Greg Kroah-Hartman To: Zijun Hu Cc: "Rafael J. Wysocki" , linux-kernel@vger.kernel.org, Zijun Hu Subject: Re: [PATCH] driver core: bus: Mark an impossible error path with WARN_ON() in bus_add_driver() Message-ID: <2024091530-antacid-magical-8302@gregkh> References: <20240915-bus_add_driver_fix-v1-1-ce5cf1f66601@quicinc.com> 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=us-ascii Content-Disposition: inline In-Reply-To: <20240915-bus_add_driver_fix-v1-1-ce5cf1f66601@quicinc.com> On Sun, Sep 15, 2024 at 06:22:05PM +0800, Zijun Hu wrote: > From: Zijun Hu > > driver_attach() called by bus_add_driver() always returns 0, so its > corresponding error path will never happen, hence mark the impossible > error path with WARN_ON() to remind readers to disregard it. So you just caused the machine to crash and reboot if that happens (remember, panic-on-warn is enabled in a few billion Linux systems...) > Signed-off-by: Zijun Hu > --- > drivers/base/bus.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/base/bus.c b/drivers/base/bus.c > index 657c93c38b0d..59a48edda267 100644 > --- a/drivers/base/bus.c > +++ b/drivers/base/bus.c > @@ -673,7 +673,7 @@ int bus_add_driver(struct device_driver *drv) > klist_add_tail(&priv->knode_bus, &sp->klist_drivers); > if (sp->drivers_autoprobe) { > error = driver_attach(drv); > - if (error) > + if (WARN_ON(error)) What exactly are you trying to show here? If this really can never fail, then let's just remove the check entirely. thanks, greg k-h