From patchwork Sun Jun 19 12:31:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathias Krause X-Patchwork-Id: 9186117 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 855EC601C0 for ; Sun, 19 Jun 2016 12:31:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 72BD525E13 for ; Sun, 19 Jun 2016 12:31:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 656EF2821F; Sun, 19 Jun 2016 12:31:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C471225E13 for ; Sun, 19 Jun 2016 12:31:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751761AbcFSMb4 (ORCPT ); Sun, 19 Jun 2016 08:31:56 -0400 Received: from mail-wm0-f67.google.com ([74.125.82.67]:34935 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751744AbcFSMbz (ORCPT ); Sun, 19 Jun 2016 08:31:55 -0400 Received: by mail-wm0-f67.google.com with SMTP id a66so2753237wme.2 for ; Sun, 19 Jun 2016 05:31:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EKPWCPxRlOB0azZMggok7E/EDP2so3rtuIUtXTZt/Ro=; b=f3WgTWv33q0BBPYcGHK2cZHSe8h3sa193BRpJFQ7ZjcSgV0gUsms5057axbTUfiYpl e6sP1DpB4mBWIjd6qeFtYIpDoStRXmfeRqITLxraVQ7mHIK1YYAliMsNt3neziurryND AlgUhnzDu/oljWoZ1K4g+rr/8S7hFtY4NmeGKuYRv78kshPPsD6xZAdIO2QCwZnXozfn MTCp0kf5JYfBNmpl4Q0CLKOBTXlSVD1ldSnO2XXgLhdCf0VBZ5KQrL3XVPue+4f5C5hX gVeBYh5NkiXo7J7SBhJrLrH15RDAal0xBxe7AtI4+fyB3pgKNAQZyXXUqhjQ2pwhk5nZ 6B4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EKPWCPxRlOB0azZMggok7E/EDP2so3rtuIUtXTZt/Ro=; b=RbQ07Iz13o956mI1Wci9HF5NpZCWTuLBsfd0S3O6tuIE0/oOPgujfGy2xGMRq1kUwB Jp2fm++/YLJkNml90ggqygVfNGAh4FtRzNWoWq54nMqtg1fFn8qFlJColgBNGsXQgLu0 FoKbqXGrgoa7kfcXYcYe3DZ1G1XPjKX13/7gs8gMnnxGKiSk36xOk+sIOlMDt/pSXu2a 6s7Mt8XUlx1ZHwMRfU582Xg00xvKFLkEECb7gW/ksY5Vpf2HoTlxmShb1b3ZV17z8uRJ MpqLe7M5dG0uLBM+IKQ7NFIsqzFsaEGX2h9/sh2LtDzMrjdidL33kKSc1PzkWMFDjBrC ZRng== X-Gm-Message-State: ALyK8tL/ELv8HpM+S8VX/hjMG8f6CLoezoF9QW7bJLyZW+/LnE56Qkpk7DUGuVaL+nZAxQ== X-Received: by 10.194.221.37 with SMTP id qb5mr9635993wjc.171.1466339513770; Sun, 19 Jun 2016 05:31:53 -0700 (PDT) Received: from jig.fritz.box ([84.179.22.43]) by smtp.gmail.com with ESMTPSA id g3sm58348678wjb.47.2016.06.19.05.31.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 Jun 2016 05:31:53 -0700 (PDT) From: Mathias Krause To: Sumit Semwal Cc: Brad Spengler , PaX Team , linux-media@vger.kernel.org, dri-devel@lists.freedesktop.org, linaro-mm-sig@lists.linaro.org, Mathias Krause , Daniel Vetter Subject: [PATCH 1/3] dma-buf: propagate errors from dma_buf_describe() on debugfs read Date: Sun, 19 Jun 2016 14:31:29 +0200 Message-Id: <1466339491-12639-2-git-send-email-minipli@googlemail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1466339491-12639-1-git-send-email-minipli@googlemail.com> References: <1466339491-12639-1-git-send-email-minipli@googlemail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The callback function dma_buf_describe() returns an int not void so the function pointer cast in dma_buf_show() is wrong. dma_buf_describe() can also fail when acquiring the mutex gets interrupted so always returning 0 in dma_buf_show() is wrong, too. Fix both issues by avoiding the indirection via dma_buf_show() and call dma_buf_describe() directly. Rename it to dma_buf_debug_show() to get it in line with the other functions. This type mismatch was caught by the PaX RAP plugin. Signed-off-by: Mathias Krause Cc: Sumit Semwal Cc: Daniel Vetter Cc: Brad Spengler Cc: PaX Team --- drivers/dma-buf/dma-buf.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c index 6355ab38d630..7094b19bb495 100644 --- a/drivers/dma-buf/dma-buf.c +++ b/drivers/dma-buf/dma-buf.c @@ -824,7 +824,7 @@ void dma_buf_vunmap(struct dma_buf *dmabuf, void *vaddr) EXPORT_SYMBOL_GPL(dma_buf_vunmap); #ifdef CONFIG_DEBUG_FS -static int dma_buf_describe(struct seq_file *s) +static int dma_buf_debug_show(struct seq_file *s, void *unused) { int ret; struct dma_buf *buf_obj; @@ -879,17 +879,9 @@ static int dma_buf_describe(struct seq_file *s) return 0; } -static int dma_buf_show(struct seq_file *s, void *unused) -{ - void (*func)(struct seq_file *) = s->private; - - func(s); - return 0; -} - static int dma_buf_debug_open(struct inode *inode, struct file *file) { - return single_open(file, dma_buf_show, inode->i_private); + return single_open(file, dma_buf_debug_show, NULL); } static const struct file_operations dma_buf_debug_fops = { @@ -913,7 +905,7 @@ static int dma_buf_init_debugfs(void) return err; } - err = dma_buf_debugfs_create_file("bufinfo", dma_buf_describe); + err = dma_buf_debugfs_create_file("bufinfo", NULL); if (err) pr_debug("dma_buf: debugfs: failed to create node bufinfo\n");