Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp6814863pxb; Wed, 17 Feb 2021 14:24:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJwiDuZwNCeEuAC3mSpHgjxIOxOGgam04BBRavV/wwXvqUmHYv/Os5FREE7di3PH/LCLfuWB X-Received: by 2002:a17:906:9b86:: with SMTP id dd6mr1089028ejc.516.1613600682809; Wed, 17 Feb 2021 14:24:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613600682; cv=none; d=google.com; s=arc-20160816; b=sEuOHxUcgDh7/f283T6jEuw9OzbUX1kEy13U+JHNrI5FoezXhVabSDR/7DohkCyzQH 77EknUAs3ewr6YM+weqzTOwDfxcxiP2O1mSafk9kdSt8ietQqg95wS/oVcAJfhVrQg+4 OnmcJuMDaeJhXIvnJWc2TAPOk34atm2XbEcg604WzjfaNWs4qDDTOARrHSbJJXm9xlbt VCYt/coGYG+byFn9SgVJ2GrTRyzT5g67ESxIMqAyqKPSpQcLQk+wVlQLMdh2CMCBShF0 VsfNxHQDnk3/Z1l6EQl8LaI6HFPlhqnaWxN5b4+4804HtczeRKqnlxuYJquh4xVg2KwU DgQA== 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=smbTqrlF1OKSavBRXV32uMxPnySvhK57w5+UGPsp0pE=; b=IjmQpYh3MzxDC5+kxARuTlYsXOGfeOYjEwwjomHK2FdLPJHg8u79ZzSP8BqegiIIRt dYFP0SGUrrki15/qzYfqgokUembGg/zRWVvwps9ZpdBVv+74437yWKkaWWqCc0GSUf+P o7ihxe7/tdLtNr/lzO6v7VV/DpN9v5nbyVAK3KG8Zk88wcvOlaB4mFkegl79jsaP/L2M rRLO85S4Lz56XL8o3yHU1MaoweO1dF9hoFIgagHkr6wnC20kC1iVxwARqumLFGAaWVWA 8VKXJmPTXEhgMvRJwwzlNn2KNl60tEJBa7p9/J/r9sVMqF52Lf+EPYUQwqDA6uvBOps2 alTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="iCYp/wqQ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f7si2421681eja.553.2021.02.17.14.24.17; Wed, 17 Feb 2021 14:24:42 -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=@gmail.com header.s=20161025 header.b="iCYp/wqQ"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233162AbhBQSK6 (ORCPT + 99 others); Wed, 17 Feb 2021 13:10:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233173AbhBQSKs (ORCPT ); Wed, 17 Feb 2021 13:10:48 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B0F6C061756 for ; Wed, 17 Feb 2021 10:10:06 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id z15so8927569pfc.3 for ; Wed, 17 Feb 2021 10:10:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=smbTqrlF1OKSavBRXV32uMxPnySvhK57w5+UGPsp0pE=; b=iCYp/wqQbf0lAfQyTZJC4Tpp4Uoo/e/ftBURBj65dQOsffIX9A1/b29tDwiSxSpBlV uA5Qh2XiSPPTGWSz7QgjlDHn3w/7JafCOT5gAuz+u6HdeazOqx9XKYdQBzbMYtJXHz2+ SR/ZodXHJEavXSysanbYLuEjS3DAsXNNHRhDCAhIoSg5cWeZmOmsqnmXwG2pzTng4+Uo M5MVQFkY3Ex62HWjYGrWQwEWeKCerW3u6q1GXH86KIsgfL7RA+9geTesbdc4X04W7UJB v3YGiQcgCn2Bgc4iKiyxf/N+uiZb+Qh2IBkE3SGbafsnd0iVahhD8fb9IZyttfoO8CtU nYMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=smbTqrlF1OKSavBRXV32uMxPnySvhK57w5+UGPsp0pE=; b=ttpg7xTjk5a0pYrg7X6TvsbDoawlBYvu0/WbLvmwlGbv824J5jMhHdIWBfcaDEMCSl GBRJmKc/mBIDBcs4iVX/tpeGg9FfxMbTige604BSw9wEAshxjTaWcCyHFYOn3svgRX6j lLMyFRY8Yt68dkJhkUlF7hHz8uGnMFhqcO0OdtHuIjJ7F3WGobxNwQQIIgwM4ZMlMOvZ 14gAWl840QsjtVR0YQrwBy4qAS5j5Q8NmEYdUO+IZ017Cb3/tXfWFcJkGFStFUUCFrax wpQjN4FFDLcuwfAFZqQ//uOByu36CRRystXzRNVEooD6fPAA23asuVjsT5CHCNGzPkpp Sx8g== X-Gm-Message-State: AOAM532zwgl7VG9eKe7PFDomGwEJ+bhjA16x9dpIDb4tAOmhWYfdiU3j EUt24BGMOWzNLQeEy0reJgWXOJ6drBMb8w== X-Received: by 2002:a05:6a00:15d2:b029:1b7:30c1:8495 with SMTP id o18-20020a056a0015d2b02901b730c18495mr563274pfu.32.1613585405906; Wed, 17 Feb 2021 10:10:05 -0800 (PST) Received: from atulu-ubuntu ([106.200.12.170]) by smtp.gmail.com with ESMTPSA id 202sm3062101pfv.89.2021.02.17.10.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Feb 2021 10:10:05 -0800 (PST) Date: Wed, 17 Feb 2021 23:40:00 +0530 From: Atul Gopinathan To: Greg KH Cc: abbotti@mev.co.uk, hsweeten@visionengravers.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] staging: comedi: cast to (unsigned int *) Message-ID: <20210217181000.GB10124@atulu-ubuntu> References: <20210217165907.9777-1-atulgopinathan@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Thanks! Atul