Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp973733pxb; Thu, 28 Jan 2021 05:15:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJy91lnn1/bJ2Hamvj0MkfXVDpyyvZElprtosLxbOnjRSdsr/lIg1cbAFzuO2V7xg3GTQxUt X-Received: by 2002:a17:906:d7:: with SMTP id 23mr8676485eji.108.1611839752706; Thu, 28 Jan 2021 05:15:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611839752; cv=none; d=google.com; s=arc-20160816; b=krzfizih/PSZzlG3GA8XiZttjhIDItUJOn5ILJ8+FS/dRfXZ/4PlOi15D2xtDolncc hgD/lrj0Ph0qg0d8q4zf86Mxr2GHGVTIiPly4sJrfYTQ76vT29mqkJ0Pai9ANQSH1Pl6 TjChuF1ys5KATZtW9TI2RR3FeGsfxzdMxsNCTDNSilmaj8S9sDMuCyA2sMDDvI/PsXGo PqPUGNzJMOTAaGrsm5pBXF1JyCSIFpl26eaiOM7xI27hwAQA8IjE/7zEaSnU15lLP8vO 2JSuY5OW7xCE+XN/XiWOPAI72zNgPyOP4Rl4xidgMTKVGLL7dUounOcU5K5GK5pXQ201 ZxXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=o5segPNWhAwf8F6uGoXuXnSqZgqAQDF+79BhqCsoUg0=; b=qnn46nR2Zyu+s2NM1vp/QjdMQtGYm3zqQvuzYMQ1sWb5OHXVVWuSnbkiNhR54MXaCj LzEywTuY48h6IJoGAlJxMtdSgPMw8Z4Pn2O1PmDGYHYwKxJ3K2g6TW+RDhnKaFM/yXLp g4RO6VGSm+/9wButyLWmQqcFeDrkOr5v+0183reGu8vHLWogvswJVdAPgV5ux7EjuF/j FB14kmvv6BvaLbc3PlfPiftYrRgu7ISDoEX7UjsUnEKBjeQoLYtk1ANuZMp+7uiSaXwZ bz4f1C7NFT+1Sod9Ov14lHeM1Eg11+mwkW5jCo5hqljFV8aBDqJ+u1/yuoz3mXs5T9Cq 43fQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d23si2487297ejd.151.2021.01.28.05.15.28; Thu, 28 Jan 2021 05:15:52 -0800 (PST) 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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231377AbhA1NMD (ORCPT + 99 others); Thu, 28 Jan 2021 08:12:03 -0500 Received: from youngberry.canonical.com ([91.189.89.112]:39718 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231797AbhA1NLj (ORCPT ); Thu, 28 Jan 2021 08:11:39 -0500 Received: from 1.general.cking.uk.vpn ([10.172.193.212] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1l574Y-00053e-CY; Thu, 28 Jan 2021 13:10:54 +0000 From: Colin King To: Laurent Pinchart , Mauro Carvalho Chehab , Ricardo Ribalda , linux-media@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] media: uvcvideo: Fix memory leak when gpiod_to_irq fails Date: Thu, 28 Jan 2021 13:10:54 +0000 Message-Id: <20210128131054.637715-1-colin.king@canonical.com> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Colin Ian King Currently when the call to gpiod_to_irq fails the error return path does not kfree the recently allocated object 'unit'. Fix this by kfree'ing it before returning. Addresses-Coverity: ("Resource leak") Fixes: 2886477ff987 ("media: uvcvideo: Implement UVC_EXT_GPIO_UNIT") Signed-off-by: Colin Ian King --- drivers/media/usb/uvc/uvc_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/media/usb/uvc/uvc_driver.c b/drivers/media/usb/uvc/uvc_driver.c index 1abc122a0977..56f867790ef1 100644 --- a/drivers/media/usb/uvc/uvc_driver.c +++ b/drivers/media/usb/uvc/uvc_driver.c @@ -1543,6 +1543,7 @@ static int uvc_gpio_parse(struct uvc_device *dev) if (irq != EPROBE_DEFER) dev_err(&dev->udev->dev, "No IRQ for privacy GPIO (%d)\n", irq); + kfree(unit); return irq; } -- 2.29.2