From patchwork Thu Jul 23 08:24:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 6851651 Return-Path: X-Original-To: patchwork-linux-sparse@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 284C2C05AC for ; Thu, 23 Jul 2015 08:24:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 56D43206A4 for ; Thu, 23 Jul 2015 08:24:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5894020694 for ; Thu, 23 Jul 2015 08:24:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751689AbbGWIYY (ORCPT ); Thu, 23 Jul 2015 04:24:24 -0400 Received: from userp1040.oracle.com ([156.151.31.81]:43222 "EHLO userp1040.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751325AbbGWIYX (ORCPT ); Thu, 23 Jul 2015 04:24:23 -0400 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id t6N8ONiR009776 (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jul 2015 08:24:23 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.13.8/8.13.8) with ESMTP id t6N8OMQQ025208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 23 Jul 2015 08:24:23 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by aserv0121.oracle.com (8.13.8/8.13.8) with ESMTP id t6N8OMYP022683 for ; Thu, 23 Jul 2015 08:24:22 GMT Received: from mwanda (/154.0.139.178) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 23 Jul 2015 01:24:21 -0700 Date: Thu, 23 Jul 2015 11:24:14 +0300 From: Dan Carpenter To: linux-sparse@vger.kernel.org Subject: [PATCH] ptrlist: reading deleted items in NEXT_PTR_LIST() Message-ID: <20150723082414.GA30778@mwanda> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-Source-IP: userv0022.oracle.com [156.151.31.74] Sender: linux-sparse-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-sparse@vger.kernel.org X-Spam-Status: No, score=-8.1 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 you call DELETE_CURRENT_PTR(), then you can sometimes end up with a __list->nr that is zero. The FOR_EACH_PTR() macro can handle this but the NEXT_PTR_LIST() macro returns ptr = 0xf0f0f0f0 which leads to a segfault. Signed-off-by: Dan Carpenter --- ptrlist.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ptrlist.h b/ptrlist.h index 58d3bda..61e159f 100644 --- a/ptrlist.h +++ b/ptrlist.h @@ -97,6 +97,8 @@ static inline void *last_ptr_list(struct ptr_list *list) } else { \ __list = __list->next; \ ptr = NULL; \ + while (__list->nr == 0 && __list != __head) \ + __list = __list->next; \ if (__list != __head) { \ __nr = 0; \ ptr = PTR_ENTRY(__list,0); \