From patchwork Mon Mar 4 20:18:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 2214351 Return-Path: X-Original-To: patchwork-cifs-client@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 8327ADF2F2 for ; Mon, 4 Mar 2013 20:18:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932478Ab3CDUSd (ORCPT ); Mon, 4 Mar 2013 15:18:33 -0500 Received: from mail-vc0-f181.google.com ([209.85.220.181]:62838 "EHLO mail-vc0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932225Ab3CDUSb (ORCPT ); Mon, 4 Mar 2013 15:18:31 -0500 Received: by mail-vc0-f181.google.com with SMTP id f13so3614186vcb.40 for ; Mon, 04 Mar 2013 12:18:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=+dGnzzSeEN7TsRdtrQnbr7xMB8nMsPSVotfnqsGYEis=; b=JLmyMd2uN5s+rHloDgpVUy2H2iHlyhWMtOekw4d4oEjhdH9kWFQcR1hGM9NdIHZXoc my/QO4VXqNnfpRVwReEwhYVuR9pbR5DPSuYozcu9h4HYcgSs8B5tOqVxBo0ljXyOlrYq 9zDItdfdKpN0V6i95Vm42axQ6Rwbv0YELlIBGvHQGc67N8jP3ng8nyOJYvWlBKSNyuy0 5BxHs0B0FD/1aTtFlZtallIk3chz4/SL5OuGQCiiTfuzUo/0TofvpvksVPeLvNFG4TrE QNiECrM4HbcmWY8OUCB5L7dbHxhwkBIrOSPA1JziDDNz3nHGvhhV+tXBbXWaqWzXur69 u4Ow== X-Received: by 10.52.22.194 with SMTP id g2mr7386406vdf.91.1362428310585; Mon, 04 Mar 2013 12:18:30 -0800 (PST) Received: from salusa.poochiereds.net (cpe-107-015-113-143.nc.res.rr.com. [107.15.113.143]) by mx.google.com with ESMTPS id dh7sm4946266vdb.0.2013.03.04.12.18.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 04 Mar 2013 12:18:30 -0800 (PST) From: Jeff Layton To: smfrench@gmail.com Cc: linux-cifs@vger.kernel.org, aia21@cam.ac.uk Subject: [PATCH] cifs: don't try to unlock pagecache page after releasing it Date: Mon, 4 Mar 2013 15:18:25 -0500 Message-Id: <1362428305-26502-1-git-send-email-jlayton@redhat.com> X-Mailer: git-send-email 1.7.11.7 X-Gm-Message-State: ALoCoQkBWs76psMil/jlNWHiQX/1NYtU748j1WbmGwodB/OOmmqnIrWehhy/qcJrnM9/jqWD7B0B Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org We had a recent fix to fix the release of pagecache pages when cifs_writev_requeue writes fail. Unfortunately, it releases the page before trying to unlock it. At that point, the page might be gone by the time the unlock comes in. Unlock the page first before checking the value of "rc", and only then end writeback and release the pages. The page lock isn't required for any of those operations so this should be safe. Reported-by: Anton Altaparmakov Signed-off-by: Jeff Layton --- fs/cifs/cifssmb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 7353bc5..8e2e799 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c @@ -1909,12 +1909,12 @@ cifs_writev_requeue(struct cifs_writedata *wdata) } while (rc == -EAGAIN); for (i = 0; i < wdata->nr_pages; i++) { + unlock_page(wdata->pages[i]); if (rc != 0) { SetPageError(wdata->pages[i]); end_page_writeback(wdata->pages[i]); page_cache_release(wdata->pages[i]); } - unlock_page(wdata->pages[i]); } mapping_set_error(inode->i_mapping, rc);