From patchwork Sat Dec 14 03:26:18 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 22468 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 407CB23908 for ; Sat, 14 Dec 2013 03:26:56 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id rd3sf2700510pab.7 for ; Fri, 13 Dec 2013 19:26:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=BQe77gc6QQv6cuNl5JZtAulqRHBbxbsGetjO4Si3pBo=; b=cjz0smOh/IiXJWJxked6Jwz9mLyVJpORnznaZE9kojzxQ+05JBEtlLkWuJp9a/USxs priqK01RTMQSMEeRJmcK9tZ5o7JFVRhA+T0QRXvxhNBIu8JM0+0eICVO9s0AVghc99oT S0rD9gg7ud+0ZjtiFem1OuPoCS3MbtRqIkrFjbGMEqKPcHPmmoCsGVS8YoNxM0ZIdmQx mZptbIK9ZkitTDXBitxB8FYJrFaqqbbpy/lfHDwQVZzbOcKEEvXDYAfy4l+OcaHLGLBt bV2NNIUUArI1F2a1MwF1NmyzUoYfyWmLlBeRR/cI1cFrXKI0QrikNHsCJuLCmk5fb41z yILw== X-Gm-Message-State: ALoCoQl6XrP0soLLoH7fFAoyYhqK7n0pRB3aG1t8qz9Ah1hHUzTRSt9ZYGGMwlV8riIcZf06FPA8 X-Received: by 10.66.146.65 with SMTP id ta1mr3735063pab.19.1386991615407; Fri, 13 Dec 2013 19:26:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.25.196 with SMTP id e4ls1302299qeg.6.gmail; Fri, 13 Dec 2013 19:26:55 -0800 (PST) X-Received: by 10.58.186.198 with SMTP id fm6mr2652472vec.16.1386991615294; Fri, 13 Dec 2013 19:26:55 -0800 (PST) Received: from mail-ve0-f176.google.com (mail-ve0-f176.google.com [209.85.128.176]) by mx.google.com with ESMTPS id ug9si1422346vcb.107.2013.12.13.19.26.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:26:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.176; Received: by mail-ve0-f176.google.com with SMTP id oz11so1936047veb.21 for ; Fri, 13 Dec 2013 19:26:55 -0800 (PST) X-Received: by 10.58.246.136 with SMTP id xw8mr2547244vec.41.1386991615214; Fri, 13 Dec 2013 19:26:55 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp86936vcz; Fri, 13 Dec 2013 19:26:54 -0800 (PST) X-Received: by 10.66.146.199 with SMTP id te7mr7211167pab.106.1386991614487; Fri, 13 Dec 2013 19:26:54 -0800 (PST) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by mx.google.com with ESMTPS id pt8si2959946pac.221.2013.12.13.19.26.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:26:54 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.46 is neither permitted nor denied by best guess record for domain of john.stultz@linaro.org) client-ip=209.85.220.46; Received: by mail-pa0-f46.google.com with SMTP id kl14so788795pab.5 for ; Fri, 13 Dec 2013 19:26:54 -0800 (PST) X-Received: by 10.66.142.107 with SMTP id rv11mr7260437pab.17.1386991614112; Fri, 13 Dec 2013 19:26:54 -0800 (PST) Received: from localhost.localdomain (c-67-170-153-23.hsd1.or.comcast.net. [67.170.153.23]) by mx.google.com with ESMTPSA id nw11sm11680086pab.13.2013.12.13.19.26.50 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 13 Dec 2013 19:26:53 -0800 (PST) From: John Stultz To: LKML Cc: Greg KH , Android Kernel Team , Sumit Semwal , Jesse Barker , Colin Cross , John Stultz Subject: [PATCH 098/115] ion: Fix two small issues in system_heap allocation Date: Fri, 13 Dec 2013 19:26:18 -0800 Message-Id: <1386991595-6251-6-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1386991595-6251-1-git-send-email-john.stultz@linaro.org> References: <1386973529-4884-1-git-send-email-john.stultz@linaro.org> <1386991595-6251-1-git-send-email-john.stultz@linaro.org> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: john.stultz@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.128.176 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , In testing ion system heap allocations, I ran across two issues: 1) Not k*z*allocing the sg table. This can cause trouble if we end up trying call sg_alloc_table() with too many entries, then sg_alloc_table() internally fails and tries to free what it thinks is internal table structure, which causes bad pointer traversals. 2) The second list_for_each_entry probably should be _safe, since I was seeing strange lock warnings and oopses on occasion. This seems to resolve it, but could use some extra checking. Signed-off-by: John Stultz --- drivers/staging/android/ion/ion_system_heap.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/staging/android/ion/ion_system_heap.c b/drivers/staging/android/ion/ion_system_heap.c index 9250ee5..bec9d45 100644 --- a/drivers/staging/android/ion/ion_system_heap.c +++ b/drivers/staging/android/ion/ion_system_heap.c @@ -166,8 +166,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap, max_order = info->order; i++; } - - table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); + table = kzalloc(sizeof(struct sg_table), GFP_KERNEL); if (!table) goto err; @@ -189,7 +188,7 @@ static int ion_system_heap_allocate(struct ion_heap *heap, err1: kfree(table); err: - list_for_each_entry(info, &pages, list) { + list_for_each_entry_safe(info, tmp_info, &pages, list) { free_buffer_page(sys_heap, buffer, info->page, info->order); kfree(info); }