Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1236733ybl; Sat, 17 Aug 2019 22:41:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqyijGYpzoXOyLLPtVaVc8QD5xSV9UJP1iTBzqNIpx5ZCy3BIyX2nxeFUh4yGnwX+F6dfzeb X-Received: by 2002:a63:9249:: with SMTP id s9mr14136349pgn.356.1566106906254; Sat, 17 Aug 2019 22:41:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566106906; cv=none; d=google.com; s=arc-20160816; b=KL287CTt8A0sRRo+oZhwVpHaWmGur21TPvAVYp/y1aXvJWPZVjRgF0brkSmuEeSLw0 f0/3QmYlaLB5218EG7opRCWwqnxyvHySMRyljrNSMN2mMw0zQH4Pbr0U4j3RohVp/KIN DQhTJqxfHxh5VcHUCNn2vF7fz8EpA03f3wKmggckIgSA567foTQdVCyYq6GWR2lqmHYi K46n0nq1CT7hcCekOd15LQKHeJvzBxPqjc7BTe1+58W4rUdj/62C7qyOm/CTI3DBrBsg Rip0Yy67AmazDEJq7cQ8QNbFq/3fRFHUTD/S3i/HkynBjtfdr7iLK1ps7yQjRLGyZAlV /ADQ== 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=8KNmPAyZv2I1Th1hHKIYw/8aVgXMRn127vv6L099Klw=; b=YH43y9uHtXLQ+rR4H5L1IPOZ3P4M+P9pU43cr73kbvh6eTDtMWz0lUxpNGhqxYf01V DmurzkCGKYN6m0WvjHSMX5ksBprYB19IvBtu1Ymg9D+BBfaLTprnmh/bNCjZFlVeiCsz /VBkN2bnfg/OZtztRJIXN2OUp6N8+XvTd3a1HOpoqzZkH1ZkJhMnLZz9tXBblEhjHxxb efdlavZ8HOJVYVmpBDr4D834tzrcGrBOh1gIeU5ZrlhSScJ9xGD6Cxbr6JVInIp37jXL +rICiki2FYz2tuop/3qmW+WYcQ+0sLFumxmmuTzicyKkTpHSiNF1VXyCQq0Lq8FsX87b LYjg== 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 g6si7451998plt.310.2019.08.17.22.41.31; Sat, 17 Aug 2019 22:41:46 -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 S1726351AbfHRFk0 (ORCPT + 99 others); Sun, 18 Aug 2019 01:40:26 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:39007 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbfHRFkZ (ORCPT ); Sun, 18 Aug 2019 01:40:25 -0400 Received: by mail-yb1-f194.google.com with SMTP id s142so3299173ybc.6; Sat, 17 Aug 2019 22:40:25 -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=8KNmPAyZv2I1Th1hHKIYw/8aVgXMRn127vv6L099Klw=; b=iGvimq+kuvZxaHLY5eAAe1b8J1/MPSzSfozef/GcYfEBIHTtXUyv9P9pD3rLz528uw KAHGrjr4YZZGNWbmu5lr9EtgY/AVgITth27jVvRWxO4jSObb3q+NprUGNH3mFnMcgcOv H5xhVGS8FLV02jwvJ0TYllCeJpKvccoHSGeJZjePw7fyCaXFCSFPnavKXsU6Q50FTCTo 5UiTMV70YBXUKcooLCY5mNwpllYekwbrMC7mUehxWWMmT4ymfbi9pmZa2PJMIw0TUDd/ 8pn7xZlPkry0JdJLDlNm6WsHXI8eqC1Jk8Ha7PkNggrZirfxM1SuEmFMXox+V3OoJAxZ zJAQ== X-Gm-Message-State: APjAAAWB1UD64Dd/fXEGW8JtygMT0jDIeLhC+sqkddFAJvFIeOktvQiE C9VooFMFv0da/i0y0wxLb8iV9O76bnc= X-Received: by 2002:a25:84d0:: with SMTP id x16mr11948162ybm.481.1566106824834; Sat, 17 Aug 2019 22:40:24 -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 g3sm1932974ywk.15.2019.08.17.22.40.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 17 Aug 2019 22:40:24 -0700 (PDT) From: Wenwen Wang To: Wenwen Wang Cc: Hans Verkuil , Mauro Carvalho Chehab , linux-media@vger.kernel.org (open list:SAA7146 VIDEO4LINUX-2 DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH v2] media: saa7146: add cleanup in hexium_attach() Date: Sun, 18 Aug 2019 00:40:14 -0500 Message-Id: <1566106814-2911-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 If saa7146_register_device() fails, no cleanup is executed, leading to memory/resource leaks. To fix this issue, perform necessary cleanup work before returning the error. Signed-off-by: Wenwen Wang --- drivers/media/pci/saa7146/hexium_gemini.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/media/pci/saa7146/hexium_gemini.c b/drivers/media/pci/saa7146/hexium_gemini.c index dca20a3..f962269 100644 --- a/drivers/media/pci/saa7146/hexium_gemini.c +++ b/drivers/media/pci/saa7146/hexium_gemini.c @@ -292,6 +292,9 @@ static int hexium_attach(struct saa7146_dev *dev, struct saa7146_pci_extension_d ret = saa7146_register_device(&hexium->video_dev, dev, "hexium gemini", VFL_TYPE_GRABBER); if (ret < 0) { pr_err("cannot register capture v4l2 device. skipping.\n"); + saa7146_vv_release(dev); + i2c_del_adapter(&hexium->i2c_adapter); + kfree(hexium); return ret; } -- 2.7.4