Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4239093ybg; Tue, 29 Oct 2019 04:19:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzkoyoLp34aNA3RGOrZkoR819EudbE8OCK6MxJ5aMbfRo65RoKADXMNE3mI7KipxWp8MCuN X-Received: by 2002:a50:ec0e:: with SMTP id g14mr25141281edr.274.1572347964869; Tue, 29 Oct 2019 04:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572347964; cv=none; d=google.com; s=arc-20160816; b=c95YDjLn4Vx1YSsln5ogaHjHSW5dUrT50lj7KXhW8Kl+k5p0D2L07wkl2/ZsjoY+RQ 4D172W5dv3RSQLXmKMWnNcB1d9ywORrfuHLtY7edM3tLXYZzHFk6ADxu5tzT9/Th2Qas CFZCqv+a5A3ZIAvCy/vHBk88jdvRaCZ40khCy1OyupcR7HgbMSCnminiLlZK9mgY2WMI E5mwCtUy1zI002I5FxzaI6Qc/BAN6KwmQW99S6QcZD8Wn1am9jtGoFJAgp+Yzb6eIXWO XZGj7abulfebRWypTHgtnVW3mKvqGAoDGsdWePnl2n3MSz/0VFBwfDTtGo0xyL2tgROv 7pkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=R8aCAQPt7tXsKDaniy2Dzrc4ISudeNlHfc000ItekbA=; b=RDnmejHXjHkJwhNmkeTq1pMyOOwwvzEYA0qGarx8Lc6NHbMT6sNwRWjVPNX9GFRE8h mozIqq2tHBuPtP9+Dla+7+qA3GBZPP5HAzP2D50Qs6uWUxx8sv1bdvbT6SPPt9ptNvxF 2TptGJW0OwWoh+5+ioSY1RwGjDBoJ/p6fIkzODJ1b/58/wSGHOR4oHH3xI5lPqkNweOJ qXnbkjS5leropKxstyaQIh0UwUEcq4GorqRebh+AzF5tLnAlVpY74imFfNGbdd1St8wO nxxMuxp9aF6XT3iWAQLW1cdEFPSEe+qGEeY/fd3Ax+/6ECuhoQl3TigSVbqb44harMgS yrCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=eiNLadDt; 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=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si9431352edj.107.2019.10.29.04.19.01; Tue, 29 Oct 2019 04:19:24 -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=@oracle.com header.s=corp-2019-08-05 header.b=eiNLadDt; 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=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731497AbfJ2KxO (ORCPT + 99 others); Tue, 29 Oct 2019 06:53:14 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:59242 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfJ2KxO (ORCPT ); Tue, 29 Oct 2019 06:53:14 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9TAmsZc139653; Tue, 29 Oct 2019 10:53:11 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2019-08-05; bh=R8aCAQPt7tXsKDaniy2Dzrc4ISudeNlHfc000ItekbA=; b=eiNLadDtEKIcHkCMmkMdCN1M6sKK18PySw1Lk7d2APMhhthgpuoriRtyU5azi9TjM8MR 3uxBBZe69W3XmzKVuveyf0zZAfUs1rNI+oazo9qfXPvXD87x5NlJXmv78hCV00uaS86P 4MsucSvLWU9wew8Zh5bfPwXcDTf78NJd7rjrfgh+mwBov6S3dK8TqAFay9PwcRO0d5bS 8PEzmgfqMKnwLF3kADQm0tWfhzR2tPuET7KneSt73HmvHR+Mgyf5yTVnylKNthM9Jst1 bZDrJQqPiCjJQQR+wR/YArMZ12CQw7jbb/PecUdga3FEs+JUvJ7KnC4hkDaIeoR/pkNV 5w== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by aserp2120.oracle.com with ESMTP id 2vve3q86w0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2019 10:53:10 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x9TAmL7o017939; Tue, 29 Oct 2019 10:51:10 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3030.oracle.com with ESMTP id 2vxj8fxw2c-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 29 Oct 2019 10:51:09 +0000 Received: from abhmp0014.oracle.com (abhmp0014.oracle.com [141.146.116.20]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x9TAp6KA007919; Tue, 29 Oct 2019 10:51:08 GMT Received: from kadam (/41.57.98.10) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 29 Oct 2019 03:51:05 -0700 Date: Tue, 29 Oct 2019 13:50:58 +0300 From: Dan Carpenter To: Rasmus Villemoes Cc: Luc Van Oostenryck , Dan Carpenter , linux-sparse@vger.kernel.org, LKML Subject: Re: detecting misuse of of_get_property Message-ID: <20191029104917.GI1944@kadam> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9424 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=806 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910290113 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9424 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=963 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1910290113 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This should probably work? regards, dan carpenter diff --git a/check_list.h b/check_list.h index 564bd1c2..5fa9a269 100644 --- a/check_list.h +++ b/check_list.h @@ -191,6 +191,7 @@ CK(check_nospec_barrier) CK(check_spectre) CK(check_spectre_second_half) CK(check_implicit_dependencies) +CK(check_of_get_property) /* wine specific stuff */ CK(check_wine_filehandles) diff --git a/check_of_get_property.c b/check_of_get_property.c new file mode 100644 index 00000000..b7aa8824 --- /dev/null +++ b/check_of_get_property.c @@ -0,0 +1,47 @@ +/* + * Copyright (C) 2019 Oracle. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/copyleft/gpl.txt + */ + +#include "smatch.h" +#include "smatch_slist.h" + +static int my_id; + +static void match_of_get_property(const char *fn, struct expression *expr, void *unused) +{ + struct expression *left = expr->left; + struct symbol *type; + + type = get_type(left); + if (!type || type->type != SYM_PTR) + return; + type = get_base_type(type); + if (type_bits(type) == 8) + return; + if (type->type == SYM_RESTRICT) + return; + sm_warning("'%s' returns big endian data", fn); +} + +void check_of_get_property(int id) +{ + my_id = id; + + if (option_project != PROJ_KERNEL) + return; + + add_function_assign_hook("of_get_property", &match_of_get_property, NULL); +}