Received: by 10.213.65.68 with SMTP id h4csp2182577imn; Thu, 29 Mar 2018 20:17:34 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/W4s3cVrmEfEHIkhiQzBbQMjQ7gJmXp5xgj3cdppEANBZZt9nYYYOkNNSYw1AgN83sCxSs X-Received: by 2002:a17:902:7087:: with SMTP id z7-v6mr10895099plk.315.1522379854599; Thu, 29 Mar 2018 20:17:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522379854; cv=none; d=google.com; s=arc-20160816; b=o2P0CoUlsB1mHk8rT+QAznfr7P3J4W+YuKgCLptzZVU9NGWT2JhyTKWia1pH/dl3cw HyFNGoIJ9juMouP0xxt07J5mxHnCEur8WfjvkwRyflXDivrHBn8S6P5/iKICS29NU9Lb AWYWMC4yGA8bIij2STEBKIlCvAZ2hHm2IWkdnpDYT1hq/Zlmw6eejhnvd/r44RzKQiGa Ks40+2EibN1fd0NdmT/vyRqdUvR3U0+JpMHE4KKGB9GTFgNuC3KmxRzvYqF4dvS7YYn1 AfVSUyb88mqDESBCpSDexMyBORAHSrH8kW84ifs/v/ubNTUqorFo0/kUvc8fjzm7+Jec dlLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=6KNjSVZblJb1DJPj1AsPuU38BsanGSDoRB1e1O82c1o=; b=SmSizXlXI/eVxjvV+qT1pMIH2irncXQTjko2pbef+waSG0upeozOtrpaDFOd5Nrc7q DZcT8u42BbdVi1imh1Hpg1TRd+TM1yiU3H5KrYr5C78rM7iLBHlzSBGLYxlSvcZpRO5Y IIUeqEMXssxy4a8V2okiGpK+f5Inl+Pb8lef8tGs+t9PyH3YEgbYglcGU6uhc6pv/45s H8IA9Jq0Q0RZuUbVqYn68yoCV/j6ni2w5rHdwwLkdtULakM6gO+gjytcx9Oi/WBMWHzH QHpEMBwWO9fmu4Sn9GsWFhqW8+v8bmV+qa/XJasieUnQWAJ3bBF0diQEiHBYOg/B/24y KGdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTyTm2KM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si4975766pgf.715.2018.03.29.20.17.09; Thu, 29 Mar 2018 20:17:34 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qTyTm2KM; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752696AbeC3DPX (ORCPT + 99 others); Thu, 29 Mar 2018 23:15:23 -0400 Received: from mail-pf0-f178.google.com ([209.85.192.178]:45310 "EHLO mail-pf0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751906AbeC3DPV (ORCPT ); Thu, 29 Mar 2018 23:15:21 -0400 Received: by mail-pf0-f178.google.com with SMTP id l27so4590564pfk.12; Thu, 29 Mar 2018 20:15:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=6KNjSVZblJb1DJPj1AsPuU38BsanGSDoRB1e1O82c1o=; b=qTyTm2KMgRwthNaJmim5Hbx5B492AeWWHusdT1JRni3NgMuaZ2+yvpvUgWxBPAVAUe QGkJOUI2TrCBOxK7d/llvYzUFXcBVVyI8lDEoPs+Bkd9kAqgd/lh+XgOK3tKAM1dFeRs Ra1sWSeXJWpu3qWD+oRM8luBFTNhgFjTZkjfBiPfigZeZ7ipCXW97GR6/d+GMYHE4ffP Q8/5Xqeaf+yjGEzUeO1pZYCDFc9fCFvUv4v0v6RMBOne6TZrN2X0CHR+S3zTFhT1YtIQ 20QGLyIPy/+kimmKevOucf6z1q6mQ9Ttq/762Cbden4inIG8HpOHyxXeT8glQPPrjuzl f19A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=6KNjSVZblJb1DJPj1AsPuU38BsanGSDoRB1e1O82c1o=; b=p1ITovrOx33VFGO+hzkYeIolsTwswA78NXsWmeq1GmNtfGdKkdXbLa2XGFbYvuGDkK Hu66lf4Y2jqJpYBjy3LB5iZfrJcj2AaKe/RUhe9/w1BxUJM3UH0/ci5Gh/tR8H7/+Mkk juWhVec0OzJKgv/bFZpyLZ+DSajlExVxq1ZG7ByDY2z3cvYBTNkPPHXdXaOqKKVQew4d 0FUhGhgEgu9lbSsM6aKs6GMMp7MHRxFs/HvuRTC1F+kn8Z64jiaCh3F47JY0LEBXAfgi x+ifsRz76QTd0T2VWBLfqq6+dWdvbT2+qRJxMgxVK0KeKT8X0l3MnQLCEX6hESzLihwO +IFw== X-Gm-Message-State: AElRT7HtEmzEwjXFj6uZ3BHVi9VWXzFxRSztHmHHRsX1UT7JdEAJdAbc MauJ+VJdSeXqX6Fv0xV6wDEgcsps X-Received: by 2002:a17:902:b283:: with SMTP id u3-v6mr4475924plr.381.1522379720940; Thu, 29 Mar 2018 20:15:20 -0700 (PDT) Received: from ?IPv6:2402:f000:1:1501:200:5efe:166.111.70.50? ([2402:f000:1:1501:200:5efe:a66f:4632]) by smtp.gmail.com with ESMTPSA id c62sm16030661pfk.179.2018.03.29.20.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Mar 2018 20:15:20 -0700 (PDT) Subject: Re: [PATCH v3] staging: vt6655: check for memory allocation failures To: Ji-Hun Kim , gregkh@linuxfoundation.org, forest@alittletooquiet.net Cc: dartnorris@gmail.com, santhameena13@gmail.com, julia.lawall@lip6.fr, y.k.oh@samsung.com, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org References: <1522377844-23591-1-git-send-email-ji_hun.kim@samsung.com> From: Jia-Ju Bai Message-ID: Date: Fri, 30 Mar 2018 11:15:03 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <1522377844-23591-1-git-send-email-ji_hun.kim@samsung.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018/3/30 10:44, Ji-Hun Kim wrote: > @@ -1165,10 +1205,18 @@ static int vnt_start(struct ieee80211_hw *hw) > } > > dev_dbg(&priv->pcid->dev, "call device init rd0 ring\n"); > - device_init_rd0_ring(priv); > - device_init_rd1_ring(priv); > - device_init_td0_ring(priv); > - device_init_td1_ring(priv); > + ret = device_init_rd0_ring(priv); > + if (ret) > + goto error; > + ret = device_init_rd1_ring(priv); > + if (ret) > + goto error; > + ret = device_init_td0_ring(priv); > + if (ret) > + goto error; > + ret = device_init_td1_ring(priv); > + if (ret) > + goto error; > > device_init_registers(priv); > > @@ -1178,6 +1226,8 @@ static int vnt_start(struct ieee80211_hw *hw) > ieee80211_wake_queues(hw); > > return 0; > +error: > + return ret; > } This code will lead to memory leaks when device_init_rd1_ring() fails, because the memory allocated by device_init_rd0_ring() is not freed. I think this one will be better: ret = device_init_rd0_ring(priv); if (ret) goto error_init_rd0_ring; ret = device_init_rd1_ring(priv); if (ret) goto error_init_rd1_ring; ret = device_init_td0_ring(priv); if (ret) goto error_init_td0_ring; ret = device_init_td1_ring(priv); if (ret) goto error_init_td1_ring; ...... error_init_td1_ring: device_free_td0_ring(priv); error_init_td0_ring: device_free_rd1_ring(priv); error_init_rd1_ring: device_free_rd0_ring(priv); error_init_rd0_ring: return ret; Best wishes, Jia-Ju Bai