Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbcLDFc7 (ORCPT ); Sun, 4 Dec 2016 00:32:59 -0500 Received: from m50-138.163.com ([123.125.50.138]:59810 "EHLO m50-138.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750778AbcLDFc5 (ORCPT ); Sun, 4 Dec 2016 00:32:57 -0500 From: Pan Bian To: Maxim Levitsky Cc: linux-kernel@vger.kernel.org, Pan Bian Subject: [PATCH 1/1] memstick: host: fix improper return value Date: Sun, 4 Dec 2016 13:32:52 +0800 Message-Id: <1480829572-4655-1-git-send-email-bianpan201603@163.com> X-Mailer: git-send-email 1.9.1 X-CM-TRANSID: C9GowACXz_+DqkNYFeK0IQ--.48336S3 X-Coremail-Antispam: 1Uf129KBjvdXoWrur4fGF4xtrWUGr1kXr4fXwb_yoWDAFg_ur W8Z34xWr409r1vqr1UJFyI934I93Z0grs7t3s7tasIyasrC3WDZFnavrn8Zry8uw4xCryD Gr95Xa1S9r18CjkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUvcSsGvfC2KfnxnUUI43ZEXa7IUY5b15UUUUU== X-Originating-IP: [114.243.30.33] X-CM-SenderInfo: held01tdqsiiqwqtqiywtou0bp/xtbBlwY291SISlMPiwAAsR Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 983 Lines: 31 From: Pan Bian When pci_ioremap_bar() returns a NULL pointer, the value of return variable "error" is 0. 0 means no error, which is contrary to the fact. Similarly, the return values are also improper when request_irq() or memstick_add_host() returns unexpected values. This patch fixes the bug, assigning "-ENOMEM" to variable "error" before the call to pci_ioremap_bar(). Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=188991 Signed-off-by: Pan Bian --- drivers/memstick/host/r592.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/memstick/host/r592.c b/drivers/memstick/host/r592.c index d5cfb50..eebed0a 100644 --- a/drivers/memstick/host/r592.c +++ b/drivers/memstick/host/r592.c @@ -761,6 +761,7 @@ static int r592_probe(struct pci_dev *pdev, const struct pci_device_id *id) if (error) goto error3; + error = -ENOMEM; dev->mmio = pci_ioremap_bar(pdev, 0); if (!dev->mmio) goto error4; -- 1.9.1