Received: by 10.192.165.148 with SMTP id m20csp3901050imm; Mon, 30 Apr 2018 08:15:49 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqv4jE93wr8aLEF6qAsl1JJ/gVxSflAsZanUkpR8XfFIqy+KrkaG9oSQq8yJgXD7kO26Xm2 X-Received: by 2002:a17:902:7d09:: with SMTP id z9-v6mr12984242pll.4.1525101349129; Mon, 30 Apr 2018 08:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525101349; cv=none; d=google.com; s=arc-20160816; b=AtRwhXBr1Ctk4img8N1Kb2cpF6MNhKxMaYKXV5qek9EZz78SzhT3EYVUUfeKZpsZ8B 3hQUUR9W4q0xfgwvRT4rds3SSisi0BqY0bE99Bkp5h6mPzZOGR8d1ZJFbL9xVyMwq0hE H3rlqfaG5CZXevdh6GxWEvU/1Y8dIGcK/gZ4FMYs1hZEf1ZusKuyC/OKaUsoALKvcruF 7ivsmu6rv6Tg6+ek3noCLmrDPuT6Bpy9Bsd0TAq9Wlcz90AV056gJ0wiHMfGG8vropKO oQKID04Y0vW9um6alUBYQdPkAsDQBcJcRr37/Q1w39AlKRDipla7TBGkrFt7uMbP247B 8Waw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=1L109RAXAlolgw/l70AR9/ayFbFqNYCBkBBd0hx0zBQ=; b=lN41IrklFIulPF1FRleMLI3eziBzFn2pyO4cGrCOjaIAiN7gPawq02bl3RmbqCO5EH jcAUsCnMz1oUhZTPCAmqCwOsV83U0sWzooarNZGy8EQpblp/91xbnC8h4KMaxdGAG+bM 8gWI6eIwMuKmqJVG2UoKNbo/WbvosZwpCdl7znbtTL828l1fFjfJ1lLKfI7dPe4lQRUN 2UojipHH1uXL1sPfZ8UOCPf0bT5LeKzg+bzaLAn2MpFnrTvIS9w1NiPlcEUDthDctDJd 3g9cJak9lYwX37zMREQ7LU28HCg/ef4pQpzuYNN4eDAQhrOMAypOh2qL/yedhOWK6n4C Wj6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k15si7447566pfi.54.2018.04.30.08.15.33; Mon, 30 Apr 2018 08:15:49 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754664AbeD3PPJ (ORCPT + 99 others); Mon, 30 Apr 2018 11:15:09 -0400 Received: from nblzone-211-213.nblnetworks.fi ([83.145.211.213]:45622 "EHLO hillosipuli.retiisi.org.uk" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752255AbeD3PPG (ORCPT ); Mon, 30 Apr 2018 11:15:06 -0400 Received: from valkosipuli.localdomain (valkosipuli.retiisi.org.uk [IPv6:2001:1bc8:1a6:d3d5::80:2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by hillosipuli.retiisi.org.uk (Postfix) with ESMTPS id EDE66634C54; Mon, 30 Apr 2018 18:15:03 +0300 (EEST) Received: from sakke by valkosipuli.localdomain with local (Exim 4.89) (envelope-from ) id 1fDAW7-0001wO-Kl; Mon, 30 Apr 2018 18:15:03 +0300 Date: Mon, 30 Apr 2018 18:15:03 +0300 From: Sakari Ailus To: Laurent Pinchart Cc: Colin King , Mauro Carvalho Chehab , linux-media@vger.kernel.org, kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH][next] media: ispstat: don't dereference user_cfg before a null check Message-ID: <20180430151503.d3kq2zomil6uh2xf@valkosipuli.retiisi.org.uk> References: <20180424130618.18211-1-colin.king@canonical.com> <20180426083731.72bmygsp2waf3eeu@valkosipuli.retiisi.org.uk> <2302951.d1m0yxIoYN@avalon> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2302951.d1m0yxIoYN@avalon> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 26, 2018 at 01:03:15PM +0300, Laurent Pinchart wrote: > Hi Sakari, > > On Thursday, 26 April 2018 11:37:31 EEST Sakari Ailus wrote: > > On Tue, Apr 24, 2018 at 02:06:18PM +0100, Colin King wrote: > > > From: Colin Ian King > > > > > > The pointer user_cfg (a copy of new_conf) is dereference before > > > new_conf is null checked, hence we may have a null pointer dereference > > > on user_cfg when assigning buf_size from user_cfg->buf_size. Ensure > > > this does not occur by moving the assignment of buf_size after the > > > null check. > > > > > > Detected by CoverityScan, CID#1468386 ("Dereference before null check") > > > > > > Fixes: 68e342b3068c ("[media] omap3isp: Statistics") > > > Signed-off-by: Colin Ian King > > > > Thanks for the patch. > > > > Gustavo sent effectively the same patch a moment earlier, and that patch > > got applied instead. > > Isn't there a guarantee that new_buf won't be NULL ? The new_buf pointer comes > from the parg variable in video_usercopy(), which should always point to a > valid buffer given that the ioctl number specifies a non-zero size. Fair question. After looking at the code, I agree with you; there should be no reason to perform the check in the first place. It may have been that the function has been used differently in the past but the check should be rather removed now. I'll drop the patch. -- Sakari Ailus e-mail: sakari.ailus@iki.fi