Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp543649rdh; Wed, 14 Feb 2024 04:54:18 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVgO7GuqnOkNFSmCl6gytFEcgDbWM+iogyLSvexvcV2opH2qvzrFTHAb9NaMDW/4vx+cAzAn5TpRW/gMWMRjOrUBuJiHQD64PcS0B7dmw== X-Google-Smtp-Source: AGHT+IESUJLJDIsEvNkmAvdZ0l9wiAF+ICQ4Th3T5akVq1gqiJYwAGAglnZzhmhas6C5rFzGFYnJ X-Received: by 2002:a05:6358:e490:b0:17a:f876:4419 with SMTP id by16-20020a056358e49000b0017af8764419mr2435849rwb.31.1707915258350; Wed, 14 Feb 2024 04:54:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707915258; cv=pass; d=google.com; s=arc-20160816; b=tZEWPm0GSd02fuls+zPLkLk8iuW+OU0ULomP2zmaMYoXqpR7lFhcKDH30E5EzmG/Nr DzbOqKxLcy5r68EwarGXbJZbFPzipGtqYTYWZKFIyMkU0xsRq3+lnQi4vWwpZTxxKxlt k6zPoEtxR9Kn3ayj7NY/2qrvXJt+MTYJWwo2ChVOoPsgBDaG4BkW4f3iK5nsC9QFI775 fA4tXK102r5lKUYuKuul84kijISGv0c6ISTuUpuedeqeuF9VkzUX0Bjd8+VABnyeIujg jNuCvjGGuJs7j72B9peSrH0flAp+SnKUrOYjGIerWUIY1fSoE81SN/v/fSVnm/EC6n4U 6yeg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date; bh=HQs+po1XLBFWsF+iZ5sawcqgJqSVSYv1dn+WCRGDIZ0=; fh=L/pzngLTC1GGRSqEw0uuhAqIENrmbwo5CfK859pH3ss=; b=na4iwRHFbefMonYduSgaMMA5BKCMqcTnMvnzlF8uRWCAjbXw3s4YfGDuuFZQZ2IjjP bHC24s8IcTPKte46zM2Ta5nyVCjRKI5gxYXDLJiy20H6NOMo/a60EQJs/01S74E9Cv1C GIcvgMNAQeh7xeTP7ehRL5gc0JnXlrv6EjjUrlL5nCu/o5yfc3G13RcVK6tpYFre90Y9 kOnyFMlC05GM2F+SzmRndb1L4lkDA/ydQfDe93u9hQU+PTg1n+NuCrfaJAPJX0tzcy8p bi2tpkN7/6jAVW+ucdStgv6xBFWBLDTS98wq80EkzRSRcK4MNmFr18qgT04wCJnKX7S5 wujw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=kernel.crashing.org); spf=pass (google.com: domain of linux-kernel+bounces-65208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65208-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXlMNW/LhMqDiSyNAVz8mFEVrbT7niUZxbJW2Y6cCR1AWM1uMH0bWEeB+60dYf2oM6YTZO6RWFm5ALEUiPp4hGo63F1d/B9HSimLTdwtQ== Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id x13-20020a056a00270d00b006ddcec89d8dsi8291592pfv.194.2024.02.14.04.54.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 04:54:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=kernel.crashing.org); spf=pass (google.com: domain of linux-kernel+bounces-65208-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65208-linux.lists.archive=gmail.com@vger.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CEFC5B221E9 for ; Wed, 14 Feb 2024 12:42:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 48EFB52F63; Wed, 14 Feb 2024 12:42:52 +0000 (UTC) Received: from gate.crashing.org (gate.crashing.org [63.228.1.57]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D21E5524C9; Wed, 14 Feb 2024 12:42:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=63.228.1.57 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707914571; cv=none; b=ZJw1ZqyIbbbvS39MaFSaDfPODp0HLwuCZjkAZMdN+aP44IXI42wFJUIPqtxTqOzGxkK7R5w176qBLpHxVywku5lSG9jX44qy3b+nBFyXGlgV9BaZjYdrmNwTRLDJ8F305JrRKB/+904WZKMuGr5bR/agBxx12sRIeR4FAHjwYOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707914571; c=relaxed/simple; bh=r6TYTqFwQotruhi73e9osnG5YZSVtIWyB3/MDHVNG88=; h=Date:From:To:Cc:Subject:Message-ID:References:Mime-Version: Content-Type:Content-Disposition:In-Reply-To; b=tDX0xyjNebrNZ5Byv3m+pcju9zRiJmRjwQ+5yy/+oLRIuxurtNi2G2lyDKRu/2+6bJrtGq4KHYms0j9/9U7n1zmb1vcs5l/IooBHpATmwTO3twqpOBj1inzmFtOC2HPobFBARRaLPLKuAcM/QHeX3I6ZYhWDJKcxhZWOEuz0P5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org; spf=pass smtp.mailfrom=kernel.crashing.org; arc=none smtp.client-ip=63.228.1.57 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.crashing.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.crashing.org Received: from gate.crashing.org (localhost.localdomain [127.0.0.1]) by gate.crashing.org (8.14.1/8.14.1) with ESMTP id 41ECaQmn030022; Wed, 14 Feb 2024 06:36:26 -0600 Received: (from segher@localhost) by gate.crashing.org (8.14.1/8.14.1/Submit) id 41ECaO1V030021; Wed, 14 Feb 2024 06:36:24 -0600 X-Authentication-Warning: gate.crashing.org: segher set sender to segher@kernel.crashing.org using -f Date: Wed, 14 Feb 2024 06:36:24 -0600 From: Segher Boessenkool To: Greg Kroah-Hartman Cc: David Laight , Arnd Bergmann , "linuxppc-dev@lists.ozlabs.org" , Arnd Bergmann , "llvm@lists.linux.dev" , Nick Desaulniers , "linux-kernel@vger.kernel.org" , Nathan Chancellor , Bill Wendling , "linux-serial@vger.kernel.org" , Justin Stitt , Jiri Slaby Subject: Re: [PATCH] tty: hvc-iucv: fix function pointer casts Message-ID: <20240214123624.GB19790@gate.crashing.org> References: <20240213101756.461701-1-arnd@kernel.org> <20240213191254.GA19790@gate.crashing.org> <57d72e2ccc8245fe99982613a11c461c@AcuMS.aculab.com> <2024021426-unleveled-unhearing-8021@gregkh> 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: <2024021426-unleveled-unhearing-8021@gregkh> User-Agent: Mutt/1.4.2.3i On Wed, Feb 14, 2024 at 11:37:21AM +0100, Greg Kroah-Hartman wrote: > On Wed, Feb 14, 2024 at 09:46:33AM +0000, David Laight wrote: > > From: Segher Boessenkool > > > Sent: 13 February 2024 19:13 > > > > > > On Tue, Feb 13, 2024 at 11:17:49AM +0100, Arnd Bergmann wrote: > > > > clang warns about explicitly casting between incompatible function > > > > pointers: > > > > > > > > drivers/tty/hvc/hvc_iucv.c:1100:23: error: cast from 'void (*)(const void *)' to 'void (*)(struct > > > device *)' converts to incompatible function type [-Werror,-Wcast-function-type-strict] > > > > 1100 | priv->dev->release = (void (*)(struct device *)) kfree; > > > > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > > > Such a cast of course is explicitly allowed by 6.3.2.3/8, only calling a > > > function using a non-compatible type is UB. This warning message is > > > quite misleading. Doubly so because of the -Werror, as always. > > > > But it will get called using the wrong type. > > And (is it) fine-ibt will reject the incorrect call. > > And rightfully so, this type of casting abuse is just that, abuse. > > Almost no one should be just calling kfree() on a device pointer, I'll > look at the surrounding code as odds are something odd is going on. But > for now, this patch is correct. Yes, and I said so. My point is that the warning message pretends the cast is bad or dangerous. It is not, similar casts are the only way in C to do certain things (yes, you can always avoid it completely, by writing completely different code, like the patch does, and that sometimes is a better idea even). But the warning message is misleading and does more damage than it helps avoid. Segher