Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3079745imb; Mon, 4 Mar 2019 23:54:03 -0800 (PST) X-Google-Smtp-Source: APXvYqy1QJCiFbIWHDsP7BAuzvTKsvyB3vuxI0Hm9aeaImtbuzoxd0voiIIvUVLtitsra6CM3A6K X-Received: by 2002:a62:ea10:: with SMTP id t16mr568894pfh.3.1551772443498; Mon, 04 Mar 2019 23:54:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551772443; cv=none; d=google.com; s=arc-20160816; b=ovOXlx1RmwAECaCKtR/PTUvMWWHOjLS4B60+/R/c7FCN9sv6/p7HPBV2HrNYcMMYfr WP2GPAsNgMWQpvVBpkYRKC60S4zQEuykfAnGtGbv+Wvfo1l6hXRgUWX445TbBE2GVkZh s0ZFBJvZGhmvlfImsv850Kh5NxdAJLgw8pCGUtmuNjWk9i8M2hgxUNdGHY018Csovuss 3gxg9BDVC5/Is0UNCUtF1rckjHAUrFhI4dErakV0IycEuZAMDeY7+5jBWJEiPaas4bqP norEjgtjVxAaeAIgiL9CmJeAKJwimPho3lxEPju8ZjomdpnXYMLlMdLhqOxRKj5iGEnc yKag== 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; bh=MyecIHix3Ns1PTqAunekEC+SEwTFQVrAe66ykH5VI5U=; b=bN7pFsNSFnOTK2iGq3+BaLBU2nqcjfIxMCojpYMktSEDmXm9c2qpJGGD32XjBOWHK7 RIRZPTWV+7/mFjp9meAUVB1b7NU6Z4n8gTTK31CGrWvCfJ6U8thrtbie1owUukAwLM2H lLraYUUZC0RnEokB/Xfl/PUIfhM0Z5qRjjJsWO14OlGZ1SFW25lmH4mW6FrQNfMz24Wf aUtxRqKds078M0T9i18uUU8UoAR8J+9TGhZ3/PgdlQ5/ljhPn/UAiEN8Be44T2HWS3Ug fbwwPAva6D5lXnnvpTSecNPkOrGEt21q24gPZ+ZURR12QpMEAwr2dHBn44IxCUz6hZ60 7nhA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q1si7483470pgm.154.2019.03.04.23.53.48; Mon, 04 Mar 2019 23:54:03 -0800 (PST) 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727312AbfCEHxY (ORCPT + 99 others); Tue, 5 Mar 2019 02:53:24 -0500 Received: from mga18.intel.com ([134.134.136.126]:44398 "EHLO mga18.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbfCEHxY (ORCPT ); Tue, 5 Mar 2019 02:53:24 -0500 X-Amp-Result: UNSCANNABLE X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 04 Mar 2019 23:53:23 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.58,443,1544515200"; d="scan'208";a="304463482" Received: from schmiger-mobl3.ger.corp.intel.com (HELO kekkonen.fi.intel.com) ([10.249.45.12]) by orsmga005.jf.intel.com with ESMTP; 04 Mar 2019 23:53:20 -0800 Received: by kekkonen.fi.intel.com (Postfix, from userid 1000) id C30A321E9B; Tue, 5 Mar 2019 09:53:18 +0200 (EET) Date: Tue, 5 Mar 2019 09:53:18 +0200 From: Sakari Ailus To: "Cao, Bingbu" Cc: Arnd Bergmann , Mauro Carvalho Chehab , Greg Kroah-Hartman , "Zhi, Yong" , "linux-media@vger.kernel.org" , "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH] media: staging/intel-ipu3: reduce kernel stack usage Message-ID: <20190305075317.4t32uyyhzftuoebp@kekkonen.localdomain> References: <20190304202758.1802417-1-arnd@arndb.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 Hi Bingbu, Arnd, On Tue, Mar 05, 2019 at 12:25:18AM +0000, Cao, Bingbu wrote: ... > > @@ -1744,7 +1745,7 @@ int imgu_css_fmt_try(struct imgu_css *css, > > struct v4l2_rect *const bds = &r[IPU3_CSS_RECT_BDS]; > > struct v4l2_rect *const env = &r[IPU3_CSS_RECT_ENVELOPE]; > > struct v4l2_rect *const gdc = &r[IPU3_CSS_RECT_GDC]; > > - struct imgu_css_queue q[IPU3_CSS_QUEUES]; > > + struct imgu_css_queue *q = kcalloc(IPU3_CSS_QUEUES, sizeof(struct > > +imgu_css_queue), GFP_KERNEL); > > Could you use the devm_kcalloc()? No, because this is not related to the device, called instead on e.g. VIDIOC_TRY_FMT. > > struct v4l2_pix_format_mplane *const in = > > &q[IPU3_CSS_QUEUE_IN].fmt.mpix; > > struct v4l2_pix_format_mplane *const out = @@ -1753,6 +1754,11 @@ > > int imgu_css_fmt_try(struct imgu_css *css, > > &q[IPU3_CSS_QUEUE_VF].fmt.mpix; > > int i, s, ret; > > > > + if (!q) { > > + ret = -ENOMEM; > > + goto out; > > + } > [Cao, Bingbu] > The goto here is wrong, you can just report an error, and I prefer it is next to the alloc. I agree, the goto is just not needed. > > + > > /* Adjust all formats, get statistics buffer sizes and formats */ > > for (i = 0; i < IPU3_CSS_QUEUES; i++) { > > if (fmts[i]) > > @@ -1766,7 +1772,8 @@ int imgu_css_fmt_try(struct imgu_css *css, > > IPU3_CSS_QUEUE_TO_FLAGS(i))) { > > dev_notice(css->dev, "can not initialize queue %s\n", > > qnames[i]); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto out; > > } > > } > > for (i = 0; i < IPU3_CSS_RECTS; i++) { @@ -1788,7 +1795,8 @@ int > > imgu_css_fmt_try(struct imgu_css *css, > > if (!imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_IN]) || > > !imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_OUT])) { > > dev_warn(css->dev, "required queues are disabled\n"); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto out; > > } > > > > if (!imgu_css_queue_enabled(&q[IPU3_CSS_QUEUE_OUT])) { @@ -1829,7 > > +1837,8 @@ int imgu_css_fmt_try(struct imgu_css *css, > > ret = imgu_css_find_binary(css, pipe, q, r); > > if (ret < 0) { > > dev_err(css->dev, "failed to find suitable binary\n"); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto out; > > } > > css->pipes[pipe].bindex = ret; > > > > @@ -1843,7 +1852,8 @@ int imgu_css_fmt_try(struct imgu_css *css, > > IPU3_CSS_QUEUE_TO_FLAGS(i))) { > > dev_err(css->dev, > > "final resolution adjustment failed\n"); > > - return -EINVAL; > > + ret = -EINVAL; > > + goto out; > > } > > *fmts[i] = q[i].fmt.mpix; > > } > > @@ -1859,7 +1869,10 @@ int imgu_css_fmt_try(struct imgu_css *css, > > bds->width, bds->height, gdc->width, gdc->height, > > out->width, out->height, vf->width, vf->height); > > > > - return 0; > > + ret = 0; > > +out: > > + kfree(q); > > + return ret; > > } > > > > int imgu_css_fmt_set(struct imgu_css *css, -- Regards, Sakari Ailus sakari.ailus@linux.intel.com