Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5801200imu; Mon, 26 Nov 2018 05:28:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/U3RsvvK0Kl4VIdSFGGd05IXD4fbWgoZnUfeLUX7kFqtG1Q/ycbgsauM/9KfgJHWvJLv1Ku X-Received: by 2002:a17:902:4523:: with SMTP id m32mr27591144pld.53.1543238931995; Mon, 26 Nov 2018 05:28:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543238931; cv=none; d=google.com; s=arc-20160816; b=rvhWl8qwSGqPQiQu/tiawahdF3qc08fnqOp3H2udqqdW6Yvm6IR2F1GISyxXkMDnT5 GlLfzLH9S/zj23U1WO6wcCsefylC4HdyUHovcsVTEW1ma3eM/qosOCf17LzpK4cdVFr1 giXckCUOcfx6h88+verHr9hm2A5ujemOGjZu28XIWKd8dqHeern0OTVjK7wqxnOkCwny YxKoRis0wp/V49CS91b04GZlkjQMjWZMsAYsCRsiROr/08/fEtk6VjbP3FzGXo8Sa1s5 mQugwM99LBdC9B0V/RDSKraFOKnylw9gAJ4d6jxHFyE7sCEA8bmy+YxCJsLEBDQgScsi OWbA== 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=84AL21H5oIBu7C7QJwmgflKv66+weMV8UjZZJKyxnLo=; b=t8leOQl5ySn0FovZ1mT9gYU9oOlooxMg+56G9g2f/sMGKgtu5D5/A7YCNmHpXeqe6c nmI25O/oUQoqdxXGRt+czy7bk7dybU+9fMHbsOYk+9iyklbDdg+Z92ghPmUICPPDpxHJ 0xO9XPwCcuETBzgheYQtNZr8yTT1emZ5eM/TKrwKiIBNzxNWpQJG8vAB5Dz965/XTu+t SBINMG0ttO50Jv9LHP3Vz4GH3SEZUn2a7M33K1uKSv5R8hIHoru/oa3knDAdM6kNzHiU mIbWqj/WoOtCnf0SmLHJLGjyTR/Q064nOIww0snei5D+SL57XQ1HhvgrqFj21uuTMIgj pgeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=oD+AzEYC; 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 v14si289880pfc.76.2018.11.26.05.28.12; Mon, 26 Nov 2018 05:28:51 -0800 (PST) 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-2018-07-02 header.b=oD+AzEYC; 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 S1726355AbeK0AV3 (ORCPT + 99 others); Mon, 26 Nov 2018 19:21:29 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:34934 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725966AbeK0AV3 (ORCPT ); Mon, 26 Nov 2018 19:21:29 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id wAQDNW0B170618; Mon, 26 Nov 2018 13:26:31 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-2018-07-02; bh=84AL21H5oIBu7C7QJwmgflKv66+weMV8UjZZJKyxnLo=; b=oD+AzEYCuLIXBPqOxDxyU9kp6+FcUsqM75LddFxQfTownD7Btkcn57zIZfF7JN5HWmqE bFAn/p4PEwqYSidN/YpvQ7yk6SzRFUFyeTC3azwv9LbgIlYwOd4CTG07S6V8krX+HzIv PbXJql6yu5eYDkbuhwHvvMsKcjtXABBcNNY7aVya0xpRbZ7i+axaqNeJML2b6D3a/FGI evnITXWHi6ZSEmARdTlmgw3xkcUTHo5GT/0OkxzlGjYtIYjh1wq3YfTcqRbp+ub8zlza ORyiAnIMgIEgGLvVHmn+TVb9/TMwFnLWCHUwEzMXCJVoNQU12pJs/ly9Db0BTQk0HaY7 uQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp2130.oracle.com with ESMTP id 2nxx2twp82-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Nov 2018 13:26:31 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id wAQDQP1R023723 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 26 Nov 2018 13:26:25 GMT Received: from abhmp0006.oracle.com (abhmp0006.oracle.com [141.146.116.12]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id wAQDQOuM008474; Mon, 26 Nov 2018 13:26:24 GMT Received: from unbuntlaptop (/41.202.241.51) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 26 Nov 2018 05:26:23 -0800 Date: Mon, 26 Nov 2018 16:26:13 +0300 From: Dan Carpenter To: Nicholas Mc Guire Cc: Nicholas Mc Guire , Lars-Peter Clausen , devel@driverdev.osuosl.org, Michael Hennerich , linux-iio@vger.kernel.org, Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Peter Meerwald-Stadler , Hartmut Knaack , Jonathan Cameron Subject: Re: [PATCH] staging: iio: adc: ad7280a: check for devm_kasprint() failure Message-ID: <20181126132612.GJ2970@unbuntlaptop> References: <1543225144-27468-1-git-send-email-hofrat@osadl.org> <20181126130032.GJ3088@unbuntlaptop> <20181126131009.GA19931@osadl.at> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126131009.GA19931@osadl.at> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9088 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=595 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1811260122 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 02:10:09PM +0100, Nicholas Mc Guire wrote: > On Mon, Nov 26, 2018 at 04:00:32PM +0300, Dan Carpenter wrote: > > On Mon, Nov 26, 2018 at 10:39:04AM +0100, Nicholas Mc Guire wrote: > > > devm_kasprintf() may return NULL on failure of internal allocation thus > > > the assignments to attr.name are not safe if not checked. On error > > > ad7280_attr_init() returns a negative return so -ENOMEM should be > > > OK here (passed on as return value of the probe function). > > > > > > Signed-off-by: Nicholas Mc Guire > > > Fixes: 2051f25d2a26 ("iio: adc: New driver for AD7280A Lithium Ion Battery Monitoring System2") > > > --- > > > > > > Problem located with an experimental coccinelle script > > > > > > As using if(!st->iio_attr[cnt].dev_attr.attr.name) seamed quite > > > unreadable in this case the (var == NULL) variant was used. Not > > ^^ > > Why two spaces? > > just a typo > > > > > > sure if there are objections against this (checkpatch.pl issues > > > a CHECK on this). > > > > > > > You should just follow checkpatch rules here. If you don't, someone > > else will just send a patch to make it checkpatch compliant. One thing > > you could do is at the start of the loop do: > > > > struct iio_dev_attr *attr = &st->iio_attr[cnt]; > > > > Then it becomes: > > > > if (!attr->dev_attr.attr.name) > > > > It's slightly more readable that way. Keep in mind that we increment > > cnt++ in the middle of the loop so you'll have to update attr as well. > > > My understanding was that CHECK: notes are not strict rules but > those that may vary from case to case. Checkpatch is just a script. It's not a genius or the king of the world. Sometimes checkpatch compliant code is clearly worse than breaking the rules. But fighting against checkpatch is a huge hassle so you should avoid it if you can. I actually agree with checkpatch on this one but it's a minor thing. Sometimes a maintainer will get obsessed with minor things. You have to be a bit obsessed to be a good kernel maintainer. Anyway, they have their fights with checkpatch and it creates a small thread every time a newbie sends a patch. And everyone on the CC list has to endure it as well. Btw, when I get annoyed with checkpatch, I feel like it's pretty obvious I am correct. I'm not like other kernel developers who have debatable style preferences... ;) regards, dan carpenter