From patchwork Sat Sep 8 03:34:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Yongjun X-Patchwork-Id: 1426241 Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id B41E0DF283 for ; Sat, 8 Sep 2012 03:35:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751781Ab2IHDeh (ORCPT ); Fri, 7 Sep 2012 23:34:37 -0400 Received: from mail-qc0-f174.google.com ([209.85.216.174]:65486 "EHLO mail-qc0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751333Ab2IHDeg convert rfc822-to-8bit (ORCPT ); Fri, 7 Sep 2012 23:34:36 -0400 Received: by qcro28 with SMTP id o28so154309qcr.19 for ; Fri, 07 Sep 2012 20:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=EOlhzbdjTyvIfOvd5YQJtXFUVziqqjUki9zsffuYU5U=; b=Cw6SQf8zJpik2wEEdhkAbGFqFitpCZEaj2MANPemdMxMiruFTYqi8TCRmATIr1vgFf /pfXtKNsyIuk1BpY8ZSBbDQTbCykP0lE8jVtiKHzpy/CWUCN89t+9l1eFlUPXHtrEIA/ 3ZbnH7Bm0KGCtXRNeDAMX9tMmS6YLBcsxlXdmAdsT0RbtPyL+5gbmxMObr3ImR3IC4Sb LTWH9mUYtXV/xQpYG9Pz99Zgl7qbQG4IPIH0q/JhIJg7xHunbKOuBSz9TlcWuBsVrRQ2 EjB6++Lr8pGv9PNWxyt88kG1jU+m1pnE9qn9N/iqnfuHtDGa9C9r4OfYHD+88mo/EAzn briA== MIME-Version: 1.0 Received: by 10.224.178.4 with SMTP id bk4mr3470233qab.38.1347075273513; Fri, 07 Sep 2012 20:34:33 -0700 (PDT) Received: by 10.229.146.194 with HTTP; Fri, 7 Sep 2012 20:34:33 -0700 (PDT) Date: Sat, 8 Sep 2012 11:34:33 +0800 Message-ID: Subject: Re: [PATCH v2] NFC: pn544_hci: move the dereference below the NULL test From: Wei Yongjun To: Larry.Finger@lwfinger.net Cc: lauro.venancio@openbossa.org, aloisio.almeida@openbossa.org, sameo@linux.intel.com, yongjun_wei@trendmicro.com.cn, linux-wireless@vger.kernel.org Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 09/08/2012 10:03 AM, Larry Finger wrote: > On 09/07/2012 08:53 PM, Wei Yongjun wrote: >> From: Wei Yongjun >> >> The dereference should be moved below the NULL test. >> >> spatch with a semantic match is used to found this. >> (http://coccinelle.lip6.fr/) >> >> Signed-off-by: Wei Yongjun >> --- >> > > As long as you are reworking this section, doesn't BUG_ON seem a little harsh? I do not think the kernel should ever be crashed because a non-essential driver is messed up. As the patch would be a totally different change, it should be a new submission, but I think each of these conditions should trigger a WARN_ON_ONCE, and return IRQ_NONE when they occur. > You means the should be like this? --- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/nfc/pn544_hci.c b/drivers/nfc/pn544_hci.c index aa71807..e42b100 100644 --- a/drivers/nfc/pn544_hci.c +++ b/drivers/nfc/pn544_hci.c @@ -341,13 +341,16 @@ flush: static irqreturn_t pn544_hci_irq_thread_fn(int irq, void *dev_id) { struct pn544_hci_info *info = dev_id; - struct i2c_client *client = info->i2c_dev; + struct i2c_client *client; struct sk_buff *skb = NULL; int r; - BUG_ON(!info); - BUG_ON(irq != info->i2c_dev->irq); + if (!info || irq != info->i2c_dev->irq) { + WARN_ON_ONCE(1); + return IRQ_NONE; + } + client = info->i2c_dev; dev_dbg(&client->dev, "IRQ\n"); if (info->hard_fault != 0)