From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91354C433E0 for ; Wed, 17 Feb 2021 18:11:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 64AA364E4A for ; Wed, 17 Feb 2021 18:11:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233233AbhBQSLC (ORCPT ); Wed, 17 Feb 2021 13:11:02 -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-Google-Smtp-Source: ABdhPJwJXdQeytcmBSrD7wMQDbQj12GCNRhhCvIy+S3PRCufhtd2+luzJUoIFOfzC05AV7KPMSVJOg== 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