Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp4071923ybl; Mon, 26 Aug 2019 05:10:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqyGbS7viGXo/Z9XCwtAqRX9QYJ4cTmyj8FvL1cjOfP5+N3LDtwBOZSMf8/9xeP7a2//y+XP X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr18790447plb.239.1566821419524; Mon, 26 Aug 2019 05:10:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566821419; cv=none; d=google.com; s=arc-20160816; b=QwXP+4YtO7Eprjj4nLGZwpymKrGx5Z89UvVv29TljYZybUrFYqiVcPqvThIEYPwYCR miu6XEu5PPUmx7OpPDtduiKnZeIQOmrR3Ny2LwSybS39sIxbfe4nODSFxrBWwyU6Lelm ZSMNNx0Epc/sDlW5DLBbEh66d+a6sh4lIPoUvCeGPn5qucX1SdsBH13g7++DOyMDN8r5 2waWQT6UffYp/kxM39kQkOGbvLR/KFcnt1cj5GQfk6iozxCXdMJxyruGOeTITL3UxhJ7 ym5jI07/TvKJc6gUX9CzOXCsZzP5w7FeCyU+yeYhlZ8dKFWDXSUf9xxyIJF1mqXs+mYj NBQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=vkjMvOyLAYjsUn3hcQLcj4T500qkTkw79NHIrwp+rwQ=; b=BD8LSndic9QxkDMDSND7vTcvUUcD6eCC/he7tWLAA+oBPiokOR1f87Zrkil2L+bQfa 7Xh1pE0eYD5cSQVUQcf9+osD5awnwRxiBu8+dbEHGvxqhWmdm0i7W+T+ZANoPHl9fd84 qM8S31xtMXsjnTvivnJEpvO7z7EXwO0pVM1xCzYbR0CDMVnFmODxm8SxZdPDj2jIKYRJ NLWzUrOsfa3w8X10+oZXoNGeVL1aUj1WwjGR+MoHoiXbXRoFA3E7TDxnQycqLvhi6dev 47vvTopPll2LodPqtUYi4HSxU0CoP3pjKDOkRvFN7SMCqSGxSw2ZdiYA8BTzF0p1R8VN Oguw== 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 a15si9913525pfi.48.2019.08.26.05.10.04; Mon, 26 Aug 2019 05:10:19 -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 S1731698AbfHZMI6 (ORCPT + 99 others); Mon, 26 Aug 2019 08:08:58 -0400 Received: from lb1-smtp-cloud9.xs4all.net ([194.109.24.22]:32995 "EHLO lb1-smtp-cloud9.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727182AbfHZMI5 (ORCPT ); Mon, 26 Aug 2019 08:08:57 -0400 Received: from [IPv6:2001:983:e9a7:1:3421:ddcd:2260:77e4] ([IPv6:2001:983:e9a7:1:3421:ddcd:2260:77e4]) by smtp-cloud9.xs4all.net with ESMTPA id 2DnoivsWpzaKO2DnpiEt5c; Mon, 26 Aug 2019 14:08:55 +0200 Subject: Re: [PATCH] [media] pvrusb2: qctrl.flag will be uninitlaized if cx2341x_ctrl_query() returns error code To: Yizhuo Cc: csong@cs.ucr.edu, zhiyunq@cs.ucr.edu, Mike Isely , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org References: <20190821210931.9621-1-yzhai003@ucr.edu> From: Hans Verkuil Message-ID: Date: Mon, 26 Aug 2019 14:08:52 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190821210931.9621-1-yzhai003@ucr.edu> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfDwcIT6tNO9/GVDrH0sRQt0aTUwH+fPlmRTpdVHKBckIdbH3YFr1Z6AGBVTpS6cyuw4jyZe/AcLv8ZZcWI4XxcqxmmbJNOyr6sAAKaEg9G6QwnMcR+MF u+awvo0OMh1LJe2MDzkot0Og+T5QbaD/nfMECZVsvyN3lzBwXKD7o2UTmubNJrDPdH9HCrVX7ARgH/HjHU1dxWz7KrJgS9hMeq1G9UA0yOoNEoqhNgeb9Pb2 fXhZWsir13gThVeCSgW2pQnKilpd90B2ANJw5vfwd1foeVMB88PymS7D7xZbNP80GN/QUpZKDqiE2wAT4Mk5c+toYq9qjY2qf9FpFn3I1Ylj+hlfD1en7Pu8 xnWizPNnbLOSWibg/YShLaVCoKLwnLGqAWZpUCmm1WjHBaJl3eyKYQKNeZox+UijyMq8q5chqBr6CsW6mOsIdcRCzVy433ZrP1YQTdFgfE9j/apPOKo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/21/19 11:09 PM, Yizhuo wrote: > Inside function ctrl_cx2341x_getv4lflags(), qctrl.flag > will be uninitlaized if cx2341x_ctrl_query() returns -EINVAL. > However, it will be used in the later if statement, which is > potentially unsafe. > > Signed-off-by: Yizhuo > --- > drivers/media/usb/pvrusb2/pvrusb2-hdw.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c > index ad5b25b89699..1fa05971316a 100644 > --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c > +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c > @@ -793,6 +793,7 @@ static unsigned int ctrl_cx2341x_getv4lflags(struct pvr2_ctrl *cptr) > struct v4l2_queryctrl qctrl; > struct pvr2_ctl_info *info; > qctrl.id = cptr->info->v4l_id; > + memset(&qctr, 0, sizeof(qctrl)) Please compile test your patches! This doesn't compile due to a typo (qctr -> qctrl). Also, this would overwrite qctrl.id with 0, not what you want. Instead, just do: struct v4l2_queryctrl qctrl = {}; to initialize the struct with all 0. Regards, Hans > cx2341x_ctrl_query(&cptr->hdw->enc_ctl_state,&qctrl); > /* Strip out the const so we can adjust a function pointer. It's > OK to do this here because we know this is a dynamically created >