From patchwork Fri Mar 7 21:11:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Khoroshilov X-Patchwork-Id: 3794821 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 9AAF8BF540 for ; Fri, 7 Mar 2014 21:12:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C26F820306 for ; Fri, 7 Mar 2014 21:12:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 08D4820265 for ; Fri, 7 Mar 2014 21:12:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753288AbaCGVMP (ORCPT ); Fri, 7 Mar 2014 16:12:15 -0500 Received: from mail.ispras.ru ([83.149.199.45]:44156 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752470AbaCGVMO (ORCPT ); Fri, 7 Mar 2014 16:12:14 -0500 Received: from localhost.localdomain (ppp91-77-223-225.pppoe.mtu-net.ru [91.77.223.225]) by mail.ispras.ru (Postfix) with ESMTPSA id 60240540157; Sat, 8 Mar 2014 01:12:12 +0400 (MSK) From: Alexey Khoroshilov To: Christian Lamparter Cc: Alexey Khoroshilov , "John W. Linville" , linux-wireless@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, ldv-project@linuxtesting.org Subject: [PATCH] p54usb: fix leaks at failure path in p54u_probe() Date: Sat, 8 Mar 2014 01:11:49 +0400 Message-Id: <1394226709-10763-1-git-send-email-khoroshilov@ispras.ru> X-Mailer: git-send-email 1.8.3.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If p54u_load_firmware() fails, p54u_probe() does not deallocate already allocated resources. The patch adds proper failure handling. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov Acked-by: Christian Lamparter --- drivers/net/wireless/p54/p54usb.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index 6e635cfa24c8..5df74503fd4f 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c @@ -1053,6 +1053,10 @@ static int p54u_probe(struct usb_interface *intf, priv->upload_fw = p54u_upload_firmware_net2280; } err = p54u_load_firmware(dev, intf); + if (err) { + usb_put_dev(udev); + p54_free_common(dev); + } return err; }