Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp206353ybl; Fri, 16 Aug 2019 22:30:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmMUhDFywPk/Jw5DgdQdO7DWipLCDs3H+02gQBDvXK8cV5QTXfmjVechbmY9ft91eMNCM+ X-Received: by 2002:a17:90a:c68c:: with SMTP id n12mr10561575pjt.33.1566019826940; Fri, 16 Aug 2019 22:30:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566019826; cv=none; d=google.com; s=arc-20160816; b=UDeHKJtQ1di2bulxa/dnSIkIVWi97z/DdQfS5Bp+WUW+4EZSRJOYG0x1hUqf3luD3G Z2vBRgwe0d0YfcYl6OeLezOWVYRT4zfbXdnSLdYqyDBxujR15jbGqwoPaL0IbreaXRCu ivTPOkqGfK3CGyuz3IntsKTU29kbnahZ7EO6nPedB0JRZp90QvkBAxNdahtVmsfxlvzx xzZF1HP+UJ4enF78+5aZWFYWDY/7C5N8zJHslfTTwaQsqih88vcZctdBdxf7g+CKXx9W FL1Gd5vAX+yZW5md0qopVtC37dbA1lGI6L/ytu4ZDDDH/KpUN2kW4X86HBDru9hERke6 oOCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=S1Fgry2hFdb7wuznV5MLxh7FRA3bpAQhtlorPVSGQOM=; b=M2a2+rg5tzFKBHB0vPYPMjuPT5L3tQccNqsZbO/d4O1oXkltlQJYLGYcJhy8Rb4yYy 81pdRjKxPRJ5WtVSMh49ZvrWSsc8Tx9O4N35UPwUaqVzpXbqteOAa+Rr/nd2Sg7WdDkb iUsNpCc56TPIpid9jXSaaYNSAPJllmzMFjTLJFAN12uDxds07uDoQ0ZkiLvGASrwi8Qf N5sgtFqRbdW+MxYp/kUEOQlAG+jjrliMyy7hwumVd+01DaJMqhUymCwHyuw/3PHfKw8b m6rWzvMyMDohisTLleMeQnb6shoROffvCKOSiCo2uHPxS8zrZ5XoGVMlfNvXBMCsmnan Y5sw== 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 bo7si1887590pjb.85.2019.08.16.22.30.10; Fri, 16 Aug 2019 22:30:26 -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 S1726119AbfHQF1z (ORCPT + 99 others); Sat, 17 Aug 2019 01:27:55 -0400 Received: from mail-yb1-f193.google.com ([209.85.219.193]:43619 "EHLO mail-yb1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725829AbfHQF1z (ORCPT ); Sat, 17 Aug 2019 01:27:55 -0400 Received: by mail-yb1-f193.google.com with SMTP id o82so2654763ybg.10; Fri, 16 Aug 2019 22:27:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=S1Fgry2hFdb7wuznV5MLxh7FRA3bpAQhtlorPVSGQOM=; b=f6IMOeET7vf844z0Cf1lIcGSM/TITrsLYo/y2zwv9qC/q9RSGwv4g8Pf3O07tWqjzX MYQ+XRMv75FIY6JOPQdQCb4LflTPutfwE2YB+AGy5alJD4HRl0trhGX6IoQYAwDzhTWj jhOeuDPmFea65cm2H/oo0J8om2X/0G/pbEvpAiuGTfhTzFAdSwmtUC8XwtxRAMklqghU lIlWl6T9ARZH9RU2fyw6UMUDtR83zwm8m8oQrHXzqd+uZ7hvjnd7Z3vGfbRRxOdcd7UF sVlPJ8WnLs5zFQcZC282t4h0pWJCBb25UBqbviC0ZN21tGwlnB380TzacS3EaaH3jRbj IR3A== X-Gm-Message-State: APjAAAWVjbqAlmmQ+Kfsvk9TVh1GKykYyZc57Er+R20Yyyta14yldHmP miGgUAMRISuZzTXmTvyV8OE= X-Received: by 2002:a25:e050:: with SMTP id x77mr9864861ybg.408.1566019674521; Fri, 16 Aug 2019 22:27:54 -0700 (PDT) Received: from localhost.localdomain (24-158-240-219.dhcp.smyr.ga.charter.com. [24.158.240.219]) by smtp.gmail.com with ESMTPSA id m124sm1721930ywb.13.2019.08.16.22.27.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 16 Aug 2019 22:27:53 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Mauro Carvalho Chehab , Hans Verkuil , Sakari Ailus , Kate Stewart , Allison Randal , Thomas Gleixner , Oliver Neukum , linux-media@vger.kernel.org (open list:MEDIA INPUT INFRASTRUCTURE (V4L/DVB)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH] media: cpia2_usb: fix memory leaks Date: Sat, 17 Aug 2019 00:27:46 -0500 Message-Id: <1566019668-4152-1-git-send-email-wenwen@cs.uga.edu> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In submit_urbs(), 'cam->sbuf[i].data' is allocated through kmalloc_array(). However, it is not deallocated if the following allocation for urbs fails. To fix this issue, free 'cam->sbuf[i].data' if usb_alloc_urb() fails. Signed-off-by: Wenwen Wang --- drivers/media/usb/cpia2/cpia2_usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c index 17468f7..3ab80a7 100644 --- a/drivers/media/usb/cpia2/cpia2_usb.c +++ b/drivers/media/usb/cpia2/cpia2_usb.c @@ -676,6 +676,10 @@ static int submit_urbs(struct camera_data *cam) if (!urb) { for (j = 0; j < i; j++) usb_free_urb(cam->sbuf[j].urb); + for (j = 0; j < NUM_SBUF; j++) { + kfree(cam->sbuf[j].data); + cam->sbuf[j].data = NULL; + } return -ENOMEM; } -- 2.7.4