From patchwork Tue Jun 22 13:00:19 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Krause X-Patchwork-Id: 56477 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from bombadil.infradead.org (bombadil.infradead.org [18.85.46.34]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 17998B6F10 for ; Tue, 22 Jun 2010 23:02:43 +1000 (EST) Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OR36D-0002Ob-Vj; Tue, 22 Jun 2010 13:01:09 +0000 Received: from mail.tqs.de ([62.157.136.17]) by bombadil.infradead.org with esmtp (Exim 4.72 #1 (Red Hat Linux)) id 1OR36A-0002Ni-If for linux-mtd@lists.infradead.org; Tue, 22 Jun 2010 13:01:07 +0000 Received: from unknown (HELO tq-mailsrv.tq-net.de) ([172.20.1.2]) by mail.tqs.de with ESMTP; 22 Jun 2010 15:01:02 +0200 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Subject: [PATCH]] mtdconcat: fix bug with uninitialized lock and unlock functions Date: Tue, 22 Jun 2010 15:00:19 +0200 Message-ID: <47F3F98010FF784EBEE6526EAAB078D10635E728@tq-mailsrv.tq-net.de> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Subject: [PATCH]] mtdconcat: fix bug with uninitialized lock and unlock functions Thread-Index: AcsSCiIXa4bSKIhIRO2I4WDpWUCl7A== From: "Martin Krause" To: X-CRM114-Version: 20090807-BlameThorstenAndJenny ( TRE 0.7.6 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20100622_090106_784340_551CB27E X-CRM114-Status: UNSURE ( 6.55 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.3.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 T_RP_MATCHES_RCVD Envelope sender domain matches handover relay domain X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Test if a lock or unlock function is present (pointer not NULL) before calling it, to prevent a kernel dump. Signed-off-by: Martin Krause --- drivers/mtd/mtdconcat.c | 18 ++++++++++++------ 1 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index db6de74..0a7ee03 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -541,10 +541,13 @@ static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) else size = len; - err = subdev->lock(subdev, ofs, size); + if (subdev->lock) { + err = subdev->lock(subdev, ofs, size); - if (err) - break; + if (err) + break; + } else + err = -EOPNOTSUPP; len -= size; if (len == 0) @@ -579,10 +582,13 @@ static int concat_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) else size = len; - err = subdev->unlock(subdev, ofs, size); + if (subdev->unlock) { + err = subdev->unlock(subdev, ofs, size); - if (err) - break; + if (err) + break; + } else + err = -EOPNOTSUPP; len -= size; if (len == 0)