From patchwork Mon Apr 27 17:13:13 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 6281951 Return-Path: X-Original-To: patchwork-ceph-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6FAEC9F1C2 for ; Mon, 27 Apr 2015 17:13:32 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90AC6203C4 for ; Mon, 27 Apr 2015 17:13:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AC6E6203C2 for ; Mon, 27 Apr 2015 17:13:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964884AbbD0RN2 (ORCPT ); Mon, 27 Apr 2015 13:13:28 -0400 Received: from mail-pd0-f178.google.com ([209.85.192.178]:36051 "EHLO mail-pd0-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964811AbbD0RNY (ORCPT ); Mon, 27 Apr 2015 13:13:24 -0400 Received: by pdea3 with SMTP id a3so134952176pde.3 for ; Mon, 27 Apr 2015 10:13:23 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=EKwq3VmhcyltP/LW7/fqFEldwVw9q0TloV/ZJvA9MDs=; b=bKGfI0niXfrhOM1vgzUnE7wTcQP0Ol/uWjlqLksAOURxp5sVUIF3ONWzOXdV03lx18 13Qm+Dfkfgy1CTnkF7Ei/STC8GP2lX63eeuWxKm93tYKznCIrW0YkqKEhYnqEdZ/Cq8L ZYPCotcCpEKvKojyRJz9q25h+xVuwiIHRCLIWfwmKAegNoISWwey4/UkYlMULWO0CGBP H799B8FUCMUVg2lEbp617D46JdEip/e39oNP8y8fVclBfBgG7WYcaec6LyrjSBTmK3ZG PUlBY4dSQOdEW1i6tlOWakdY82tPtgn0Uf3PzTIN4ZkJZbx0XJZDnC66KWPyuY38ihA2 ouxA== X-Gm-Message-State: ALoCoQkMBfCaUGD1eDbLuFjYJC0PdZNoySHCu5Jvxc/oX09bdt60lLg625w3MPPVxcGxBWi04FnM X-Received: by 10.70.98.233 with SMTP id el9mr24291110pdb.54.1430154803664; Mon, 27 Apr 2015 10:13:23 -0700 (PDT) Received: from shibby.corp.google.com ([104.135.1.105]) by mx.google.com with ESMTPSA id ff10sm12124675pab.13.2015.04.27.10.13.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Apr 2015 10:13:23 -0700 (PDT) From: Alex Elder To: ceph-devel@vger.kernel.org Subject: [PATCH 5/7] osd_client: improve safety of osd_req_op_data() macro Date: Mon, 27 Apr 2015 12:13:13 -0500 Message-Id: <1430154795-17123-6-git-send-email-elder@linaro.org> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1430154795-17123-1-git-send-email-elder@linaro.org> References: <1430154795-17123-1-git-send-email-elder@linaro.org> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The osd_req_op_data() macro uses (and thus evaluates) two of its parameters more than once. This isn't guaranteed safe. Define and use some local variables to fix that. Signed-off-by: Alex Elder --- net/ceph/osd_client.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 6539dfc..4602442 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -120,10 +120,13 @@ static void ceph_osd_data_bio_init(struct ceph_osd_data *osd_data, } #endif /* CONFIG_BLOCK */ -#define osd_req_op_data(oreq, whch, typ, fld) \ - ({ \ - BUG_ON(whch >= (oreq)->r_num_ops); \ - &(oreq)->r_ops[whch].typ.fld; \ +#define osd_req_op_data(oreq, whch, typ, fld) \ + ({ \ + struct ceph_osd_request *__oreq = (oreq); \ + unsigned int __whch = (whch); \ + \ + BUG_ON(__whch >= __oreq->r_num_ops); \ + &__oreq->r_ops[__whch].typ.fld; \ }) static struct ceph_osd_data *