Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6817467pxb; Wed, 17 Feb 2021 14:29:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJwq3zYX+LlEPJfWEcO/xqZwXN5C0Sux52MxUTK7axbfuSQzunFYFXcz7ANcgJ1nBf6WdJky X-Received: by 2002:a17:907:76c5:: with SMTP id kf5mr1082110ejc.534.1613600995422; Wed, 17 Feb 2021 14:29:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613600995; cv=none; d=google.com; s=arc-20160816; b=M8rpjnCTMBe69cT4GQGoE0oSyDyUkFBj6MpoRyONoCvNTeYovinTC2UFPWbKdJzbNo 6zwDqwhXEx+wScTgUClz5lADcmh7uuV3syNquvgm4nCZJs0Z0Hmgv2G49ongjzAJXIpo EC1bTr/gFju0j52LG9ea5hyVTRPn9nuy+eGl1ThHKAKdGrDc4/5vLDkLSMEh6FCLUZo+ C4n3O0W7ZYann45WvVzUm4XvkmTtOguFEPDpYJ2FlVTyCUd6pGTt67BfRGR9QNwk2F3a Sf28l4W7PbLY2qPDr+cKRA54nqldREnf70Srm6qJZxfv89g5sVufthk0NvgmAGkkXVmi teQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=v5EioaksE0YWY49tsV8ti5VkJVPb7Xf5rJxAZyjO/+Q=; b=OaNEd5d+IAvDGt3TXznVBEmXChsb7Lyt/10dE8/Yx341roKULCCyN77U9DzMfkQ8OU 2OC0bg7hBxZs2EPqrYorohGH+r0tozTkXbtAR10WDSIBBY6XocsfqgaLl+eoHdLQ1YuM OkQWwANNDybnf1kB12IVDR9uDTY/DyfXwmvmgWs8zc3gbKZtE1mMAL9jTA2y1hakzdbe 4SEg4gspaYaVKVtwujZlQVugL2xuU5zui1j1h3+SbpKWw80V1qkeIgYRAPf59pcHJHBM 8edz+Y8SnDRl4ioHh30nkhtlz2fb9BmS2k60EeDLCDwmtIm6RF1agHcO31O1/yK9UIhc hMZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zxgHkeN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a3si2808698edm.520.2021.02.17.14.29.31; Wed, 17 Feb 2021 14:29:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=zxgHkeN8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234887AbhBQS1H (ORCPT + 99 others); Wed, 17 Feb 2021 13:27:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:33388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231562AbhBQS1G (ORCPT ); Wed, 17 Feb 2021 13:27:06 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2815B64E5F; Wed, 17 Feb 2021 18:26:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1613586385; bh=q5JrprClEjItckxFH4fd1u6M1i1Z2rFwwSH4UKBTIHo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=zxgHkeN8LatoVMNUgNlQUzrzwF/hbOvs0dOqXQOj6gp8Pkmsm6le0nWMkNt7F/Q07 0oVksAHUlrfL452oDsfzGchZjO6XlkCi9fRa2TbsDld4vv7x1uYnZEgLdoeAX0Y0YC ouY45TsRjcMJ6J7Cfm3UmuHueOx+XkYgK/Bo1VOE= Date: Wed, 17 Feb 2021 19:26:22 +0100 From: Greg KH To: Atul Gopinathan , Ian Abbott Cc: devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: comedi: cast to (unsigned int *) Message-ID: References: <20210217165907.9777-1-atulgopinathan@gmail.com> <20210217181000.GB10124@atulu-ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210217181000.GB10124@atulu-ubuntu> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 17, 2021 at 11:40:00PM +0530, Atul Gopinathan wrote: > On Wed, Feb 17, 2021 at 06:35:15PM +0100, Greg KH wrote: > > On Wed, Feb 17, 2021 at 10:29:08PM +0530, Atul Gopinathan wrote: > > > Resolve the following warning generated by sparse: > > > > > > drivers/staging//comedi/comedi_fops.c:2956:23: warning: incorrect type in assignment (different address spaces) > > > drivers/staging//comedi/comedi_fops.c:2956:23: expected unsigned int *chanlist > > > drivers/staging//comedi/comedi_fops.c:2956:23: got void [noderef] * > > > > > > compat_ptr() has a return type of "void __user *" > > > as defined in "include/linux/compat.h" > > > > > > cmd->chanlist is of type "unsigned int *" as defined > > > in drivers/staging/comedi/comedi.h" in struct > > > comedi_cmd. > > > > > > Signed-off-by: Atul Gopinathan > > > --- > > > drivers/staging/comedi/comedi_fops.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/drivers/staging/comedi/comedi_fops.c b/drivers/staging/comedi/comedi_fops.c > > > index e85a99b68f31..fc4ec38012b4 100644 > > > --- a/drivers/staging/comedi/comedi_fops.c > > > +++ b/drivers/staging/comedi/comedi_fops.c > > > @@ -2953,7 +2953,7 @@ static int get_compat_cmd(struct comedi_cmd *cmd, > > > cmd->scan_end_arg = v32.scan_end_arg; > > > cmd->stop_src = v32.stop_src; > > > cmd->stop_arg = v32.stop_arg; > > > - cmd->chanlist = compat_ptr(v32.chanlist); > > > + cmd->chanlist = (unsigned int __force *)compat_ptr(v32.chanlist); > > > > __force? That feels wrong, something is odd if that is ever needed. > > > > Are you _sure_ this is correct? > > The same file has instances of "(usigned int __force *)" cast being > used on the same "cmd->chanlist". For reference: > > At line 1797 of comedi_fops.c: > 1796 /* restore chanlist pointer before copying back */ > 1797 cmd->chanlist = (unsigned int __force *)user_chanlist; > 1798 cmd->data = NULL; > > At line 1880: > 1879 /* restore chanlist pointer before copying back */ > 1880 cmd->chanlist = (unsigned int __force *)user_chanlist; > 1881 *copy = true; > > Here "user_chanlist" is of type "unsigned int __user *". > > > Or perhaps, I shouldn't be relying on them? I don't know, it still feels wrong. Ian, any thoughts? thanks, greg k-h