Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp2359980imw; Sun, 17 Jul 2022 07:10:22 -0700 (PDT) X-Google-Smtp-Source: AGRyM1sJN711fJSo2uI+t+J6p2mXd5ZOaRtni0AH7kOntwa3sT75lrkWVWJZt8PFKcxTFR4IUbg+ X-Received: by 2002:a05:6402:524d:b0:43a:72fe:76b7 with SMTP id t13-20020a056402524d00b0043a72fe76b7mr31937252edd.398.1658067022173; Sun, 17 Jul 2022 07:10:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658067022; cv=none; d=google.com; s=arc-20160816; b=DsjMic9l4jlZp3jXwgtpptQVLNEvkgGdCLhSlFKTfVA27fHatUnmBzbTxPf9YSLAGa kSwL16TLGvQV1wYgRHfDx/U86wTbvn5h1VZBY/6rHreRWWNEp2DuuAp6kYDdVSsfSavf oG2pdMvRScr0tFzeJFuQ0y9or+TAH1ZKZYT//T9nA+9d7+vSsz67kCMCUWqhH+sQU30R LlOz9BC3XIAYv7eodCxrMDZad7lrRZmgteHm2NHsCGwMwPn2/nAjJJ7i7Pqxwov28GNo 9U0c6FskBdzo0xYiBTRxnDFrVTbygU+A2u49tRBwk7X8jhVwaLYtNPJVhkKYp6rqzZBn XPyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=cFuBewbkyjB+iZbBdIas3lipeNBlzCnMmSiTJJaaLis=; b=ES/MpNQntMNUzzSLCm6D7KsKWjpy/Db9n1RVketrxNwP5JbC1Mj0EH7rPk3+kA66cn ioTZEIYRlZqz45TVh7Qwb7qIbQrToWW2sgwHziSG53frXMNyleJpxUWhlaoSHS7fgjqb E1oQryI0IsXA9a2mL0ovF7Xf/BXRxME/Cb9FbLoTJ+v2vfoZwrkWeOj9L21MHoiHSI/1 49M5kHBwZRG4n9bXGtAC/hUNkgGPJpr6+pR2XpdApEC1iUw1Obj3P6ieMEYU1rgK/9Kx Tz6VRhnZqNY0Id+zVthSnJYXPuWcTcNfscDqOORwyN8UotFUriUY8vtk2XWqezWsMlN9 0Qwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=opwd2+K3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hc13-20020a170907168d00b0072ee57126e9si14035416ejc.166.2022.07.17.07.09.56; Sun, 17 Jul 2022 07:10:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=opwd2+K3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231816AbiGQNoC (ORCPT + 99 others); Sun, 17 Jul 2022 09:44:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58402 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229463AbiGQNoA (ORCPT ); Sun, 17 Jul 2022 09:44:00 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D43DAE02E; Sun, 17 Jul 2022 06:43:59 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id bk26so13387785wrb.11; Sun, 17 Jul 2022 06:43:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=cFuBewbkyjB+iZbBdIas3lipeNBlzCnMmSiTJJaaLis=; b=opwd2+K3gwX+08GH6RAe3x11lbmVIuzg71eTgtQobjhXGWCIrqfKTi+3cEvdtmcR4n RfaxEkzBJja1Lf6lDX2GA6G6DR/XS+aZa9pJmB5ftq9Gr7JsnlrLiu2YaFnnQYFu+4Ao 4UUqoC427QOvHJjW35IW5RaLyoFLxZ32Gn6DT8uiMsPx9fC6oruZ+3cwjLjERQguLaKD O/Bbtd5AH2vcE1Mmzp//GzaFIwv0AhqQTdz6LuIDlGZHwT6B4MwBiSIUcneY77jkeSA4 EGGg2CzKYsXoiNlMWf51uteslohagS1gbhSF0obZAfSByEN2iiY5Hbl8whGTCtIdQSlm zTtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=cFuBewbkyjB+iZbBdIas3lipeNBlzCnMmSiTJJaaLis=; b=zbV1akfzfQkqnq+DkkcGJOiA/E01EalwNvrTGuutzsrvDA5ulHzi5qQP7SbZR8rEir syS4umqCjhSrplTxVMCH7o/GWw4MjvfvyI2DjnlSj92keqrH147C0gO9S5Kk3WVnqfn1 O0+ogP2KlG+Vf3YXcvGQXzG8HhqgOvf5iuefAn8pV+IjU8TBu7R4DyymHnEdTGX1g1mn kEHUZ8oBjdSkCIMeqquWMh93JPRaBbUEnRVsiG38srpCEsH+SZz6q5BSXjDanLeggJZl FwBcEPfcDwT0IRXj2+1QnM83iwanlA0azF8qa97dmEzPEQIhDUI+FuswcOICBpkrk9K4 Vp+g== X-Gm-Message-State: AJIora8mz5gfFyMD2aP7yBw8LPF2tBrInaYYJMRcMSAX3iSW5wMQOEK6 uwosIGEYDMYkGQk++FoBXRQ= X-Received: by 2002:adf:f7ce:0:b0:21d:cb21:f6ee with SMTP id a14-20020adff7ce000000b0021dcb21f6eemr12057378wrq.438.1658065438415; Sun, 17 Jul 2022 06:43:58 -0700 (PDT) Received: from elementary ([94.73.36.185]) by smtp.gmail.com with ESMTPSA id h17-20020adffd51000000b0021d746d4820sm8268430wrs.37.2022.07.17.06.43.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Jul 2022 06:43:58 -0700 (PDT) Date: Sun, 17 Jul 2022 15:43:56 +0200 From: =?iso-8859-1?Q?Jos=E9_Exp=F3sito?= To: Laurent Pinchart Cc: mchehab@kernel.org, linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, ribalda@chromium.org Subject: Re: [PATCH RESEND v2] media: uvcvideo: Fix memory leak in uvc_gpio_parse Message-ID: <20220717134356.GA246248@elementary> References: <20220108170439.49984-1-jose.exposito89@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 15, 2022 at 10:10:41PM +0300, Laurent Pinchart wrote: > Hi Jos?, > > Thank you for the patch. > > On Sat, Jan 08, 2022 at 06:04:39PM +0100, Jos? Exp?sito wrote: > > I can't believe I've managed to ignore this patch for so long :-( Sorry. Hi Laurent, No problem, thanks for reviewing it, I just emailed you v3: https://lore.kernel.org/linux-media/20220717133847.245703-1-jose.exposito89@gmail.com/T/ Jos? Exp?sito > > Previously the unit buffer was allocated before checking the IRQ for > > privacy GPIO. > > In case of error, the unit buffer was leaked. > > > > Allocate the unit buffer after the IRQ to avoid it. > > > > Addresses-Coverity-ID: 1474639 ("Resource leak") > > Fixes: 2886477ff987 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT") > > Signed-off-by: Jos? Exp?sito > > Reviewed-by: Ricardo Ribalda > > Reviewed-by: Laurent Pinchart > > > --- > > > > v2: Add Fixes and Reviewed-by tags > > --- > > drivers/media/usb/uvc/uvc_driver.c | 8 ++++---- > > 1 file changed, 4 insertions(+), 4 deletions(-) > > > > diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c > > index 7c007426e082..9e83e2002710 100644 > > --- a/drivers/media/usb/uvc/uvc_driver.c > > +++ b/drivers/media/usb/uvc/uvc_driver.c > > @@ -1533,10 +1533,6 @@ static int uvc_gpio_parse(struct uvc_device *dev) > > if (IS_ERR_OR_NULL(gpio_privacy)) > > return PTR_ERR_OR_ZERO(gpio_privacy); > > > > - unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); > > - if (!unit) > > - return -ENOMEM; > > - > > irq = gpiod_to_irq(gpio_privacy); > > if (irq < 0) { > > if (irq != EPROBE_DEFER) > > @@ -1545,6 +1541,10 @@ static int uvc_gpio_parse(struct uvc_device *dev) > > return irq; > > } > > > > + unit = uvc_alloc_entity(UVC_EXT_GPIO_UNIT, UVC_EXT_GPIO_UNIT_ID, 0, 1); > > + if (!unit) > > + return -ENOMEM; > > + > > unit->gpio.gpio_privacy = gpio_privacy; > > unit->gpio.irq = irq; > > unit->gpio.bControlSize = 1; > > -- > Regards, > > Laurent Pinchart