Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp490863pxk; Thu, 3 Sep 2020 05:24:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUaDMNGDo+MKpNzR+CFa/I8ZJ9cJKN+BBlYdYWc0xZ3KeOooJxLyy1R9dqVrogCWRWnq2X X-Received: by 2002:a17:906:1b55:: with SMTP id p21mr1901767ejg.457.1599135843814; Thu, 03 Sep 2020 05:24:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599135843; cv=none; d=google.com; s=arc-20160816; b=jgSIUMIWtlnQAsHHIYxUyq6oj4HtU947J/7UbXkN4qBw9w3HNyo2JfbxTDItFfS7Iu sL//ef4FU3U+noSqfHXi5/HfX3QlO+nHN+2smH7hhZjf58ZHH5hyXFskqtKaEqwbop1r ddKJogNrsx7CF7gtCjZFgE2EkUH4aoyqAjHFViNDn3MFEgntJt4VjLIbpFA1I7IJumG/ f9IBP0x7l9Fud5QN963PSDvIAgCbjtlZiSklCvJSEiQz0JR7r82/Fj7IdsOtFY+oXGtv N5mpZUusshByrWKzGiWBpgB2chc2ZEqpaTrSDKEU6vJH+myvkLxVSiNcThvddtK7q7mR 494Q== 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:dkim-signature; bh=QKEHKvfNrVYWGJWh0y6aRDbNrtxVaKEZU0F14eu8Z0k=; b=hClQW3E6NhAi2/kFeOt/++QJBrSzNSJZwZGvbRtQoA4UEzb3JOSykh+MHQxvyYsJ27 WDB5t3yhaqmRSBnrcwvK1yiLFQNEW78VFlmNvlHAw0gwncBeMK7UCf478LtWnPmrL8/B 60O0z1cfhTXkUJUuq8iB1hjcKN3BG1CdAefiLTrppgqXNCr5K3JrkNMYThNnHfM4mDdD U784a8wvLgTSE161rqgCt3Baj/DOyAS3IvIjwGlbREQlRMjX0mYXRWTrZ1jsdfGVQRWM CfAn/vhQe2aglXs4bubLLxlVhj2qIEyIXWM4Vqe1xBZVrm+0LwcyxRK45ZqD13TAJV9X KsjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2020-01-29 header.b=kOcgfqaS; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lx24si1724779ejb.89.2020.09.03.05.23.39; Thu, 03 Sep 2020 05:24:03 -0700 (PDT) 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=@oracle.com header.s=corp-2020-01-29 header.b=kOcgfqaS; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728790AbgICMUR (ORCPT + 99 others); Thu, 3 Sep 2020 08:20:17 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:45300 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728796AbgICMMR (ORCPT ); Thu, 3 Sep 2020 08:12:17 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 083CAB0v011875; Thu, 3 Sep 2020 12:11:44 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=QKEHKvfNrVYWGJWh0y6aRDbNrtxVaKEZU0F14eu8Z0k=; b=kOcgfqaSl0hDx5LBnVbz53kyHYtyUvtciIoZcagADbyFyowLTm8ZXJgX1kVUYiDykirV 0lEBg/ProzlzFUpyZQlV40uMpOoJyVSvtOsaDQzR7LyfSXDVz6TYj33kQ9CnaE718J2r K6aM7EzO9vLcgz97RC8+Tz6To3OmvBv0bS4hLkoq9+Ai+EYo/FBkpQR3zhNP6D8nU+cS Rpw65R+VtOT2pIFA0SroSSNz09GHNTMDMoemyhWpHb0I9MYDg1QmnH28HmHd0Oi+V+2z qykUNN+o2URswcxRep5C7rubSfO+IHBBTIKVxdoFqVlGH131UQJ50cGQEjlmBCgzFIJx ew== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 337eymg8sr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 03 Sep 2020 12:11:44 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 083CAjU8102349; Thu, 3 Sep 2020 12:11:43 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 3380x9sr94-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 03 Sep 2020 12:11:43 +0000 Received: from abhmp0002.oracle.com (abhmp0002.oracle.com [141.146.116.8]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 083CBgpd030107; Thu, 3 Sep 2020 12:11:42 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 03 Sep 2020 05:11:42 -0700 Date: Thu, 3 Sep 2020 15:11:34 +0300 From: Dan Carpenter To: Alex Dewar Cc: devel@driverdev.osuosl.org, Greg Kroah-Hartman , Linus Walleij , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, Sakari Ailus , Mauro Carvalho Chehab , Alan Cox Subject: Re: [PATCH] staging: media: atomisp: Fix error path in lm3554_probe() Message-ID: <20200903121134.GB8299@kadam> References: <20200902184207.479525-1-alex.dewar90@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200902184207.479525-1-alex.dewar90@gmail.com> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9732 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 mlxscore=0 spamscore=0 phishscore=0 mlxlogscore=999 adultscore=0 suspectscore=2 bulkscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009030115 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9732 signatures=668679 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 adultscore=0 priorityscore=1501 phishscore=0 mlxlogscore=999 mlxscore=0 lowpriorityscore=0 clxscore=1011 spamscore=0 bulkscore=0 impostorscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2006250000 definitions=main-2009030114 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 02, 2020 at 07:41:50PM +0100, Alex Dewar wrote: > The error path for lm3554_probe() contains a number of bugs, including: > * resource leaks > * jumping to error labels out of sequence > * not setting the return value appropriately > > Fix it up and give the labels more memorable names. > > This issue has existed since the code was originally contributed in > commit a49d25364dfb ("staging/atomisp: Add support for the Intel IPU v2"), > although the code was subsequently removed altogether and then > reinstated with commit ad85094b293e ("Revert "media: staging: atomisp: Remove driver""). > Almost perfect! Just a couple other leaks we should fix as well. > + ret = media_entity_pads_init(&flash->sd.entity, 0, NULL); > + if (ret) { > + dev_err(&client->dev, "error initializing media entity"); > + goto err_free_ctrl_handler; > } > > flash->sd.entity.function = MEDIA_ENT_F_FLASH; > @@ -881,20 +882,22 @@ static int lm3554_probe(struct i2c_client *client) > > timer_setup(&flash->flash_off_delay, lm3554_flash_off_delay, 0); We need to delete this timer. > > - err = lm3554_gpio_init(client); > - if (err) { > + ret = lm3554_gpio_init(client); > + if (ret) { > dev_err(&client->dev, "gpio request/direction_output fail"); > - goto fail2; > + goto err_cleanup_entity; > } > return atomisp_register_i2c_module(&flash->sd, NULL, LED_FLASH); If atomisp_register_i2c_module() fails then we need to call lm3554_gpio_uninit(client) and do other cleanup. > -fail2: > + > +err_cleanup_entity: > media_entity_cleanup(&flash->sd.entity); > +err_free_ctrl_handler: > v4l2_ctrl_handler_free(&flash->ctrl_handler); regards, dan carpenter